Example usage for javax.persistence Query setHint

List of usage examples for javax.persistence Query setHint

Introduction

In this page you can find the example usage for javax.persistence Query setHint.

Prototype

Query setHint(String hintName, Object value);

Source Link

Document

Set a query property or hint.

Usage

From source file:com.webbfontaine.valuewebb.model.util.TTUtils.java

/**
 * @return null if entity not found, true if TT is frozen, false otherwize
 *//*  w ww  .j a  v a2 s  . c o  m*/
public static Boolean isTTFreezed(long id) {
    Query query = Utils.getEntityManager().createQuery("SELECT frozen FROM TtGen tt WHERE tt.id = :id");
    query.setParameter("id", id);
    query.setHint("org.hibernate.cacheMode", CacheMode.IGNORE);
    return (Boolean) query.getSingleResult();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteSummaryDayByDateTime(Long dateTime, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("SummaryDay.deleteByDateTime").setParameter("dateTime", dateTime);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }/*from w  ww  .  ja va 2  s  . c  om*/
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteCollectDataByDateTime(Long dateTime, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("CollectData.deleteByDateTime").setParameter("dateTime", dateTime);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from  ww w  .  java 2s.  c o  m
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteSummaryHourByDateTime(Long dateTime, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("SummaryHour.deleteByDateTime").setParameter("dateTime", dateTime);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from   w  w w .java2  s . com
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteSummaryMonthByDateTime(Long dateTime, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("SummaryMonth.deleteByDateTime").setParameter("dateTime", dateTime);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }/*from  w ww.ja v a 2  s.co  m*/
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteCollectStringDataByDateTime(Long dateTime, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("CollectStringData.deleteByDateTime").setParameter("dateTime", dateTime);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from   ww w. jav  a2  s. c  om
    return query.executeUpdate();
}

From source file:com.expressui.core.dao.GenericDao.java

/**
 * Utility method for setting Hibernate hints on a query to read-only, thus enabling caching.
 *
 * @param query query to set hints on/* w ww .  j  a va  2 s.c  o  m*/
 */
public static void setReadOnly(Query query) {
    query.setHint("org.hibernate.cacheable", true);
    query.setHint("org.hibernate.cacheRegion", "ReadOnlyQuery");
    query.setHint("org.hibernate.readOnly", true);
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteEventLogByGenerationDate(Long generationDate, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("EventLogEntity.deleteByGenerationDate").setParameter("generationDate",
            generationDate);/*from w w  w .  j  a va  2s  .  c om*/
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteEventLogByGenerationDateConfigFlg(Long generationDate, int timeout) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("EventLogEntity.deleteByGenerationDateConfigFlg")
            .setParameter("generationDate", generationDate);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from   ww  w.ja  v  a  2  s  . co m
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteSummaryDayByDateTimeAndMonitorId(Long dateTime, int timeout, String monitorId) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("SummaryDay.deleteByDateTimeAndMonitorId")
            .setParameter("dateTime", dateTime).setParameter("monitorId", monitorId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }/*from   w ww. j  a  v a 2 s  .  c  o m*/
    return query.executeUpdate();
}