Example usage for org.hibernate LockMode NONE

List of usage examples for org.hibernate LockMode NONE

Introduction

In this page you can find the example usage for org.hibernate LockMode NONE.

Prototype

LockMode NONE

To view the source code for org.hibernate LockMode NONE.

Click Source Link

Document

No lock required.

Usage

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

License:Apache License

/**
 * Returns the disambiguation category.// ww w.  ja  va  2  s  .c om
 *
 * @return The disambiguation category.
 * @throws WikiApiException
 */
public Category getDisambiguationCategory() throws WikiApiException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateMetaData, LockMode.NONE);
    String disambCategoryTitle = hibernateMetaData.getDisambiguationCategory();
    session.getTransaction().commit();
    Category disambCategory = wiki.getCategory(disambCategoryTitle);
    return disambCategory;
}

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

License:Apache License

/**
 * Returns the name of the main/root category.
 *
 * @return The name of the main/root category.
 * @throws WikiApiException//from   w  ww .  j  a  va2  s. c  om
 */
public Category getMainCategory() throws WikiApiException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateMetaData, LockMode.NONE);
    String mainCategoryTitle = hibernateMetaData.getMainCategory();
    session.getTransaction().commit();
    Category mainCategory = wiki.getCategory(mainCategoryTitle);
    return mainCategory;
}

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

License:Apache License

/**
 * Returns the version of the wikipedia data.
 *
 * @return The version of the wikipedia data.
 * @throws WikiApiException/*from  w w  w  .  j  a v  a2 s  . co m*/
 */
public String getVersion() throws WikiApiException {
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    session.lock(hibernateMetaData, LockMode.NONE);
    String version = hibernateMetaData.getVersion();
    session.getTransaction().commit();
    return version;
}

From source file:de.uniwue.info6.database.map.daos.DaoTools.java

License:Apache License

@SuppressWarnings("deprecation")
public void attachClean(T instance, Session session) {
    log.debug("attaching clean T instance");
    try {/*from ww w.j  a v a2 s  .c o m*/
        session.lock(instance, LockMode.NONE);
        log.debug("attach successful");
    } catch (RuntimeException re) {
        log.error("attach failed", re);
        throw re;
    }
}

From source file:de.xwic.sandbox.security.etrack.EntityLifeKeeper.java

License:Apache License

/**
 * Refresh entities.//  www. ja  v  a  2 s .  c  om
 */
private void _refreshEntities() {

    if (entities.size() > 0) {
        Session session = HibernateUtil.currentSession();
        for (EntityRefTrack et : entities.values()) {
            session.lock(et.getEntity(), LockMode.NONE);
        }
    }
}

From source file:edu.harvard.mcz.imagecapture.data.ExternalHistoryLifeCycle.java

License:Open Source License

public void attachClean(ExternalHistory instance) {
    log.debug("attaching clean ExternalHistory instance");
    try {/*from w  ww  .  ja v  a  2  s  .co m*/
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        try {
            session.lock(instance, LockMode.NONE);
            session.getTransaction().commit();
            log.debug("attach successful");
        } catch (HibernateException e) {
            session.getTransaction().rollback();
            log.error(e.getMessage());
        }
        try {
            session.close();
        } catch (SessionException e) {
        }
    } catch (RuntimeException re) {
        log.error("attach failed", re);
        throw re;
    }
}

From source file:edu.harvard.mcz.imagecapture.data.SpecimenPartLifeCycle.java

License:Open Source License

/** Re-associate a transient instance with a session.
 * //from   w  w  w.  j av a2s.  c  om
 * @param instance
 */
public void attachClean(SpecimenPart instance) {
    log.debug("attaching clean SpecimenPart instance");
    try {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        try {
            session.lock(instance, LockMode.NONE);
            session.flush();
            session.getTransaction().commit();
            log.debug("attach successful");
        } catch (HibernateException e) {
            session.getTransaction().rollback();
            log.error("attach failed", e);
        }
        try {
            session.close();
        } catch (SessionException e) {
        }
    } catch (RuntimeException re) {
        log.error("attach failed", re);
        throw re;
    }
}

From source file:edu.harvard.mcz.imagecapture.data.UnitTrayLabelLifeCycle.java

License:Open Source License

public void attachClean(UnitTrayLabel instance) {
    log.debug("attaching clean UnitTrayLabel instance");
    try {//w w w.  j  a  v  a2 s  .c  om
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        try {
            session.lock(instance, LockMode.NONE);
            session.getTransaction().commit();
            log.debug("attach successful");
        } catch (HibernateException e) {
            session.getTransaction().rollback();
            log.error(e.getMessage());
        }
        try {
            session.close();
        } catch (SessionException e) {
        }
    } catch (RuntimeException re) {
        log.error("attach failed", re);
        throw re;
    }
}

From source file:edu.harvard.mcz.precapture.data.InventoryLifeCycle.java

License:Open Source License

public void attachClean(Inventory instance) {
    log.debug("attaching clean Inventory instance");
    try {/*  w  ww . j av  a 2 s.  c  o m*/
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        try {
            session.lock(instance, LockMode.NONE);
            session.getTransaction().commit();
            log.debug("attach successful");
        } catch (HibernateException e) {
            session.getTransaction().rollback();
            log.error(e.getMessage());
        }
        try {
            session.close();
        } catch (SessionException e) {
        }
    } catch (RuntimeException re) {
        log.error("attach failed", re);
        throw re;
    }
}

From source file:edu.ku.brc.dbsupport.HibernateUtil.java

License:Open Source License

public static void attach(Object obj, Session session) {
    try {/*ww w . j ava 2  s .  c  om*/
        session.lock(obj, LockMode.NONE);
    } catch (HibernateException he) {
        log.warn("Exception thrown in attach()", he); //$NON-NLS-1$
    }
}