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:businesslogic.distribution.resource.SystemDAO.java

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

From source file:businesslogic.distribution.resource.SystemDAO.java

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

From source file:businesslogic.distribution.ResourceAllocationDAO.java

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

From source file:businesslogic.distribution.ResourceAllocationDAO.java

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

From source file:businesslogic.support.SystemConfigurationDAO.java

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

From source file:businesslogic.support.SystemConfigurationDAO.java

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

From source file:businesslogic.utility.NotificationDAO.java

public static List queryNotification(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From businesslogic.utility.Notification as Notification");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {// ww  w. j  ava 2 s  . com
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Notification", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:businesslogic.utility.NotificationDAO.java

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

From source file:classes.Employee.java

public static List queryEmployee(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From classes.Employee as Employee");
    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("Employee", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:classes.Employee.java

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