Example usage for org.hibernate Query setLockMode

List of usage examples for org.hibernate Query setLockMode

Introduction

In this page you can find the example usage for org.hibernate Query setLockMode.

Prototype

Query<R> setLockMode(String alias, LockMode lockMode);

Source Link

Document

Set the LockMode to use for specific alias (as defined in the query's FROM clause).

Usage

From source file:dados.hibernate.DAO.ArtistaPDAO.java

public static List queryArtistaP(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From ArtistaP as ArtistaP");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//w w  w  . j  av  a2 s .  c  o m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("ArtistaP", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:dados.hibernate.DAO.ArtistaPDAO.java

public static java.util.Iterator iterateArtistaPByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From ArtistaP as ArtistaP");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from ww  w . ja  va  2 s  .c o  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("ArtistaP", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:dados.hibernate.DAO.MusicaPDAO.java

public static List queryMusicaP(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From MusicaP as MusicaP");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from w ww.  j av  a 2  s. co  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("MusicaP", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:dados.hibernate.DAO.MusicaPDAO.java

public static java.util.Iterator iterateMusicaPByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From MusicaP as MusicaP");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {// w w  w . j ava 2 s .c  om
        Query query = session.createQuery(sb.toString());
        query.setLockMode("MusicaP", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:de.innovationgate.webgate.api.jdbc.filehandling.CS5P4FileAttachmentHandler.java

License:Open Source License

@Override
protected CS5P4FileAttachmentEntity fetchFileAttachmentEntity(String strFile)
        throws WGAPIException, HibernateException {

    // We cannot query if the entity is transient
    if (((MainEntity) _entity).getCreated() == null) {
        return null;
    }//from   www .jav a  2s .c  o m

    String hqlQuery = "select cfm from " + _entityDescriptor.getHQLFileMetaEntity() + " cfm where cfm."
            + _entityDescriptor.getHQLFileMetaParentProperty() + "=:entity and cfm.name=:name";
    Query query = _handling.getParent().getSession().createQuery(hqlQuery);
    query.setLockMode("cfm", LockMode.PESSIMISTIC_READ);
    query.setParameter("entity", _entity);
    query.setParameter("name", strFile);

    Iterator<?> it = query.iterate();
    if (it.hasNext()) {
        return (CS5P4FileAttachmentEntity) it.next();
    } else {
        return null;
    }

}

From source file:diagrama_bd.base_de_datos.AdministradorDAO.java

public static List queryAdministrador(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Administrador as Administrador");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from   ww  w . jav a 2 s  .c  o m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Administrador", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:diagrama_bd.base_de_datos.AdministradorDAO.java

public static java.util.Iterator iterateAdministradorByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Administrador as Administrador");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from w  w  w. j av  a  2  s. co m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Administrador", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:diagrama_bd.base_de_datos.CanalDAO.java

public static List queryCanal(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Canal as Canal");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from   ww w.j av a2s.  c o  m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Canal", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:diagrama_bd.base_de_datos.CanalDAO.java

public static java.util.Iterator iterateCanalByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Canal as Canal");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*  www  . j av a 2  s  . c  o m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Canal", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:diagrama_bd.base_de_datos.ClienteDAO.java

public static List queryCliente(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Cliente as Cliente");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from   www  . j av a 2 s .c  o m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Cliente", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}