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.accounting.user.ManagerDAO.java

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

From source file:businesslogic.accounting.user.ManagerDAO.java

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

From source file:businesslogic.accounting.user.MiddleLevelManagerDAO.java

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

From source file:businesslogic.accounting.user.MiddleLevelManagerDAO.java

public static java.util.Iterator iterateMiddleLevelManagerByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From businesslogic.accounting.user.MiddleLevelManager as MiddleLevelManager");
    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.com*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("MiddleLevelManager", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:businesslogic.accounting.user.UserDAO.java

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

From source file:businesslogic.accounting.user.UserDAO.java

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

From source file:businesslogic.distribution.Allocation_DAO.java

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

From source file:businesslogic.distribution.Allocation_DAO.java

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

From source file:businesslogic.distribution.requirement.RequirementDAO.java

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

From source file:businesslogic.distribution.requirement.RequirementDAO.java

public static java.util.Iterator iterateRequirementByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From businesslogic.distribution.requirement.Requirement as Requirement");
    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("Requirement", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}