Example usage for org.hibernate LockMode UPGRADE

List of usage examples for org.hibernate LockMode UPGRADE

Introduction

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

Prototype

LockMode UPGRADE

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

Click Source Link

Document

An upgrade lock.

Usage

From source file:HibernateGenericDAO.GenericHibernateDAO.java

/**
 *
 * @param id/*from  w ww .  j a  v  a  2s  .c  o m*/
 * @param lock
 * @return
 */
@SuppressWarnings("unchecked")
@Override
public T findById(ID id, boolean lock) {
    this.abrirSession();
    T entity;
    if (lock)
        entity = (T) getSession().get(getPersistentClass(), id, LockMode.UPGRADE);
    else
        entity = (T) getSession().get(getPersistentClass(), id);
    this.cerrarSession();
    return entity;
}

From source file:it.geosdi.era.server.dao.hibernate.DAOProgettoHibernate.java

License:Open Source License

public Progetto findById(Long id, boolean lock) throws DAOException {
    Progetto entity;//w w  w. ja  v  a  2 s .  co  m
    try {
        if (lock) {
            entity = (Progetto) getSession().load(Progetto.class, id, LockMode.UPGRADE);
        } else {
            entity = (Progetto) getSession().load(Progetto.class, id);
        }
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
    return entity;
}

From source file:it.geosdi.era.server.dao.hibernate.DAOProgettoHibernate.java

License:Open Source License

public void lock(Progetto entity) throws DAOException {
    try {//w ww  . j  a v a  2 s. c  o  m
        getSession().lock(entity, LockMode.UPGRADE);
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
}

From source file:it.geosdi.era.server.dao.hibernate.DAOServerHibernate.java

License:Open Source License

public Server findById(Long id, boolean lock) throws DAOException {
    Server entity;//from  ww  w . j  a  v  a 2 s . c om
    try {
        if (lock) {
            entity = (Server) getSession().load(Server.class, id, LockMode.UPGRADE);
        } else {
            entity = (Server) getSession().load(Server.class, id);
        }
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
    return entity;
}

From source file:it.geosdi.era.server.dao.hibernate.DAOServerHibernate.java

License:Open Source License

public void lock(Server entity) throws DAOException {
    try {/*from  w  w w .  jav  a  2s . co m*/
        getSession().lock(entity, LockMode.UPGRADE);
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
}

From source file:it.geosdi.era.server.dao.hibernate.DAOStratoProgettoHibernate.java

License:Open Source License

public StratoProgetto findById(Long id, boolean lock) throws DAOException {
    StratoProgetto entity;//w  w  w .  j av  a 2s . c o m
    try {
        if (lock) {
            entity = (StratoProgetto) getSession().load(StratoProgetto.class, id, LockMode.UPGRADE);
        } else {
            entity = (StratoProgetto) getSession().load(StratoProgetto.class, id);
        }
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
    return entity;
}

From source file:it.geosdi.era.server.dao.hibernate.DAOStratoProgettoHibernate.java

License:Open Source License

public void lock(StratoProgetto entity) throws DAOException {
    try {/*  w w w . j a  va  2  s  .  c  o m*/
        getSession().lock(entity, LockMode.UPGRADE);
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
}

From source file:it.geosdi.era.server.dao.hibernate.DAOUtenteHibernate.java

License:Open Source License

public Utente findById(Long id, boolean lock) throws DAOException {
    Utente entity;//  ww  w. j a  va 2 s.c om
    try {
        if (lock) {
            entity = (Utente) getSession().load(Utente.class, id, LockMode.UPGRADE);
        } else {
            entity = (Utente) getSession().load(Utente.class, id);
        }
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
    return entity;
}

From source file:it.geosdi.era.server.dao.hibernate.DAOUtenteHibernate.java

License:Open Source License

public void lock(Utente entity) throws DAOException {
    try {//from ww  w .  j av a 2 s  . co m
        getSession().lock(entity, LockMode.UPGRADE);
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
}

From source file:it.geosdi.era.server.dao.hibernate.DAOUtenteProgettoHibernate.java

License:Open Source License

public UtenteProgetto findById(Long id, boolean lock) throws DAOException {
    UtenteProgetto entity;//from  w  w  w . j  a  va2 s.  com
    try {
        if (lock) {
            entity = (UtenteProgetto) getSession().load(UtenteProgetto.class, id, LockMode.UPGRADE);
        } else {
            entity = (UtenteProgetto) getSession().load(UtenteProgetto.class, id);
        }
    } catch (HibernateException ex) {
        throw new DAOException(ex);
    }
    return entity;
}