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:entities.Village.java

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

From source file:entities.Vote.java

public static List queryVote(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From entities.Vote as Vote");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from   www  . jav a2s . co m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Vote", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:entities.Vote.java

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

From source file:entities.Voter.java

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

From source file:entities.Voter.java

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

From source file:entity.CassiereDAO.java

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

From source file:entity.CassiereDAO.java

public static java.util.Iterator iterateCassiereByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From entity.Cassiere as Cassiere");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*  w  ww .ja va  2 s.  c o m*/
        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:entity.ClienteDAO.java

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

From source file:entity.ClienteDAO.java

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

From source file:entity.DescrizioneDAO.java

public static Descrizione[] listDescrizioneByQuery(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From entity.Descrizione as Descrizione");
    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  om
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        List list = query.list();
        return (Descrizione[]) list.toArray(new Descrizione[list.size()]);
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}