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:ma.massarpro.dao.impl.ProfesseurDAOImpl.java

public Professeur[] listProfesseurByQuery(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) {
    StringBuffer sb = new StringBuffer("From ma.massarpro.beans.Professeur as Professeur");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/* w  ww  .j  a  v a2s .c  o m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        List list = query.list();
        return (Professeur[]) list.toArray(new Professeur[list.size()]);
    } catch (Exception e) {
        _logger.error("listProfesseurByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new RuntimeException(e);
    }
}

From source file:ma.massarpro.dao.impl.ProfesseurDAOImpl.java

public static java.util.Iterator iterateProfesseurByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) {
    StringBuffer sb = new StringBuffer("From ma.massarpro.beans.Professeur as Professeur");
    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  om*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateProfesseurByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new RuntimeException(e);
    }
}

From source file:ma.massarpro.dao.impl.SupportDAOImpl.java

public Support[] listSupportByQuery(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) {
    StringBuffer sb = new StringBuffer("From ma.massarpro.beans.Support as Support");
    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  a2s .co m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        List list = query.list();
        return (Support[]) list.toArray(new Support[list.size()]);
    } catch (Exception e) {
        _logger.error("listSupportByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new RuntimeException(e);
    }
}

From source file:ma.massarpro.dao.impl.SupportDAOImpl.java

public static java.util.Iterator iterateSupportByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) {
    StringBuffer sb = new StringBuffer("From ma.massarpro.beans.Support as Support");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*  w  w  w .jav  a  2 s  .  co m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateSupportByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new RuntimeException(e);
    }
}

From source file:model.Box2DAO.java

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

From source file:model.Box2DAO.java

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

From source file:model.Director2DAO.java

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

From source file:model.Director2DAO.java

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

From source file:model.EspecialidadDAO.java

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

From source file:model.EspecialidadDAO.java

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