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:diagrama_de_base_de_datos.PuntoInteresDAO.java

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

From source file:diagrama_de_base_de_datos.TarifaDAO.java

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

From source file:diagrama_de_base_de_datos.TarifaDAO.java

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

From source file:diagrama_de_base_de_datos.UsuarioDAO.java

public static List queryUsuario(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From diagrama_de_base_de_datos.Usuario as Usuario");
    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  .  c o  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Usuario", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:diagrama_de_base_de_datos.UsuarioDAO.java

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

From source file:edu.mgupi.pass.db.defects.DefectClassesFactory.java

public static DefectClasses[] listDefectClassesByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.defects.DefectClasses as DefectClasses");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from   w  ww .j  a  va  2 s  .  c om*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        List list = query.list();
        return (DefectClasses[]) list.toArray(new DefectClasses[list.size()]);
    } catch (Exception e) {
        _logger.error("listDefectClassesByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.defects.DefectClassesFactory.java

public static java.util.Iterator iterateDefectClassesByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.defects.DefectClasses as DefectClasses");
    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("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error(
                "iterateDefectClassesByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.defects.DefectsFactory.java

public static Defects[] listDefectsByQuery(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.defects.Defects as Defects");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from  w w  w  .  ja  v  a  2 s  .c  om
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        List list = query.list();
        return (Defects[]) list.toArray(new Defects[list.size()]);
    } catch (Exception e) {
        _logger.error("listDefectsByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.defects.DefectsFactory.java

public static java.util.Iterator iterateDefectsByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.defects.Defects as Defects");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from  w w w .  ja v a 2s. c o  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateDefectsByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.defects.DefectTypeOptionsFactory.java

public static DefectTypeOptions[] listDefectTypeOptionsByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.defects.DefectTypeOptions as DefectTypeOptions");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//  w w  w  .j  a  v a 2 s .  com
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        List list = query.list();
        return (DefectTypeOptions[]) list.toArray(new DefectTypeOptions[list.size()]);
    } catch (Exception e) {
        _logger.error(
                "listDefectTypeOptionsByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}