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.PhysicalResourceDAO.java

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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