Example usage for org.hibernate Session lock

List of usage examples for org.hibernate Session lock

Introduction

In this page you can find the example usage for org.hibernate Session lock.

Prototype

void lock(Object object, LockMode lockMode);

Source Link

Document

Obtain the specified lock level upon the given object.

Usage

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * Returns a set containing the children (subcategories) of this category.
 * @return A set containing the children (subcategories) of this category.
 *//*from   www .java  2  s .  co  m*/
public Set<Category> getChildren() {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getOutLinks());
    session.getTransaction().commit();

    Set<Category> categories = new HashSet<Category>();
    for (int pageID : tmpSet) {
        categories.add(this.wiki.getCategory(pageID));
    }
    return categories;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * @return A set containing the IDs of the children of this category.
 *///from ww w  .java 2 s  . com
public Set<Integer> getChildrenIDs() {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getOutLinks());
    session.getTransaction().commit();
    return tmpSet;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * Returns the title of the category.//from w  ww . j a va2  s .  co  m
 * @return The title of the category.
 * @throws WikiTitleParsingException
 */
public Title getTitle() throws WikiTitleParsingException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    String name = hibernateCategory.getName();
    session.getTransaction().commit();
    Title title = new Title(name);
    return title;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * Returns the set of pages that are categorized under this category.
 * @return The set of pages that are categorized under this category.
 * @throws WikiApiException//from   www.  j  a  v  a  2  s . c  o m
 * @deprecated Use {@link #getArticles()} instead.
 */
@Deprecated
public Set<Page> getPages() throws WikiApiException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getPages());
    session.getTransaction().commit();

    Set<Page> pages = new HashSet<Page>();
    for (int pageID : tmpSet) {
        pages.add(this.wiki.getPage(pageID));
    }
    return pages;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * Returns the set of articles that are categorized under this category.
 * @return The set of articles that are categorized under this category.
 * @throws WikiApiException/*  w  w w  .j a v a2 s .co  m*/
 */
public Set<Page> getArticles() throws WikiApiException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getPages());
    session.getTransaction().commit();

    Set<Page> pages = new HashSet<Page>();
    for (int pageID : tmpSet) {
        pages.add(this.wiki.getPage(pageID));
    }
    return pages;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * Returns the set of article ids that are categorized under this category.
 * @return The set of article ids that are categorized under this category.
 * @throws WikiApiException/*from  w  w w .j  av a  2s. c  o m*/
 */
public Set<Integer> getArticleIds() throws WikiApiException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getPages());
    session.getTransaction().commit();

    return tmpSet;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java

License:Apache License

/**
 * This method exposes implementation details and should not be made public.
 * It is used for performance tuning./*from  ww  w.  jav a 2  s  . c o m*/
 * @return The set of pages that are categorized under this category.
 * @throws WikiPageNotFoundException
 */
protected Set<Integer> __getPages() throws WikiPageNotFoundException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateCategory, LockMode.NONE);
    Set<Integer> tmpSet = new HashSet<Integer>(hibernateCategory.getPages());
    session.getTransaction().commit();
    return tmpSet;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.MetaData.java

License:Apache License

/**
 * Returns the id of the MetaData object.
 *
 * @return The id of the MetaData object.
 *///w  w  w  .  j av  a 2  s  .co m
public long getId() {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateMetaData, LockMode.NONE);
    long id = hibernateMetaData.getId();
    session.getTransaction().commit();
    return id;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.MetaData.java

License:Apache License

/**
 * Returns the number of categories in the current Wikipedia.
 *
 * @return The number of categories in the current Wikipedia.
 *///  w  w w  . j  a  va  2s .  c om
public long getNumberOfCategories() {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateMetaData, LockMode.NONE);
    long nrofCategories = hibernateMetaData.getNrofCategories();
    session.getTransaction().commit();
    return nrofCategories;
}

From source file:de.tudarmstadt.ukp.wikipedia.api.MetaData.java

License:Apache License

/**
 * Returns the number of pages in the current Wikipedia.
 *
 * @return The number of pages in the current Wikipedia.
 *//*  ww w. j  a va 2 s. c o  m*/
public long getNumberOfPages() {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateMetaData, LockMode.NONE);
    long nrofPages = hibernateMetaData.getNrofPages();
    session.getTransaction().commit();
    return nrofPages;
}