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:entity.UtenteDAO.java

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

From source file:entityclasses.Survey_response.java

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

From source file:entityclasses.Survey_response.java

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

From source file:entitymodelling.ormweek11.EmployeeDAO.java

public static List queryEmployee(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From entitymodelling.ormweek11.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.j a  v  a  2 s  .com*/
        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:entitymodelling.ormweek11.EmployeeDAO.java

public static java.util.Iterator iterateEmployeeByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From entitymodelling.ormweek11.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  .j a v 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);
    }
}

From source file:entitymodelling.ormweek11.SalesDAO.java

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

From source file:entitymodelling.ormweek11.SalesDAO.java

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

From source file:es.tekniker.eefrmwrk.gcm.mng.dao.domain.Gcmregistration.java

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

From source file:es.tekniker.eefrmwrk.gcm.mng.dao.domain.Gcmregistration.java

public static java.util.Iterator iterateGcmregistrationByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From es.tekniker.eefrmwrk.gcm.mng.dao.Gcmregistration as Gcmregistration");
    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 . co m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Gcmregistration", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:es.tekniker.eefrmwrk.monitoring.tac.dao.domain.DuplicateValueDAO.java

public static List queryDuplicateValue(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From es.tekniker.eefrmwrk.monitoring.tac.dao.domain.DuplicateValue as DuplicateValue");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from   w  ww.  j  av  a  2s .  c o m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("DuplicateValue", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}