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:edu.mgupi.pass.db.locuses.LocusModuleDataFactory.java

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

From source file:edu.mgupi.pass.db.locuses.LocusSourcesFactory.java

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

From source file:edu.mgupi.pass.db.locuses.LocusSourcesFactory.java

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

From source file:edu.mgupi.pass.db.sensors.SensorClassesFactory.java

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

From source file:edu.mgupi.pass.db.sensors.SensorClassesFactory.java

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

From source file:edu.mgupi.pass.db.sensors.SensorsFactory.java

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

From source file:edu.mgupi.pass.db.sensors.SensorsFactory.java

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

From source file:edu.mgupi.pass.db.sensors.SensorTypesFactory.java

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

From source file:edu.mgupi.pass.db.sensors.SensorTypesFactory.java

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

From source file:edu.mgupi.pass.db.surfaces.MaterialsFactory.java

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