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:eu.epichub.gateway.eg.core.impl.gateway_subscriptionDAOImpl.java

public java.util.Iterator iterateGateway_subscriptionByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From eu.epichub.gateway.eg.core.gateway_subscription as gateway_subscription");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from  w ww  . j a  v a2s. c om
        Query query = session.createQuery(sb.toString());
        query.setLockMode("gateway_subscription", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error(
                "iterateGateway_subscriptionByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:eu.epichub.gateway.eg.core.impl.gateway_valueDAOImpl.java

public List queryGateway_value(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From eu.epichub.gateway.eg.core.gateway_value as gateway_value");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*w  w w  .  j  ava 2s  .  co m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("gateway_value", lockMode);
        return query.list();
    } catch (Exception e) {
        _logger.error("listGateway_valueByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:eu.epichub.gateway.eg.core.impl.gateway_valueDAOImpl.java

public java.util.Iterator iterateGateway_valueByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From eu.epichub.gateway.eg.core.gateway_value as gateway_value");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from  w w w  .  jav  a2  s. com*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("gateway_value", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error(
                "iterateGateway_valueByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:eu.epichub.gateway.eg.core.impl.gateway_variableDAOImpl.java

public List queryGateway_variable(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From eu.epichub.gateway.eg.core.gateway_variable as gateway_variable");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from  w  w w  . ja v a2  s.c o m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("gateway_variable", lockMode);
        return query.list();
    } catch (Exception e) {
        _logger.error(
                "listGateway_variableByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:eu.epichub.gateway.eg.core.impl.gateway_variableDAOImpl.java

public java.util.Iterator iterateGateway_variableByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From eu.epichub.gateway.eg.core.gateway_variable as gateway_variable");
    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  . c o  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("gateway_variable", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error(
                "iterateGateway_variableByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:eventapp.impl.AttachmentDAOImpl.java

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

From source file:eventapp.impl.AttachmentDAOImpl.java

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

From source file:eventapp.impl.CommentDAOImpl.java

public List queryComment(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From eventapp.Comment as Comment");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/* w w  w .j av a2s.c  o m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Comment", lockMode);
        return query.list();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:eventapp.impl.CommentDAOImpl.java

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

From source file:eventapp.impl.EventCategoryDAOImpl.java

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