/** * Prepare the given Query object, applying cache settings and/or * a transaction timeout. * @param queryObject the Query object to prepare * @see #setCacheQueries * @see #setQueryCacheRegion */ @SuppressWarnings({"rawtypes", "deprecation"}) protected void prepareQuery(org.hibernate.Query queryObject) { if (isCacheQueries()) { queryObject.setCacheable(true); if (getQueryCacheRegion() != null) { queryObject.setCacheRegion(getQueryCacheRegion()); } } if (getFetchSize() > 0) { queryObject.setFetchSize(getFetchSize()); } if (getMaxResults() > 0) { queryObject.setMaxResults(getMaxResults()); } ResourceHolderSupport sessionHolder = (ResourceHolderSupport) TransactionSynchronizationManager.getResource(obtainSessionFactory()); if (sessionHolder != null && sessionHolder.hasTimeout()) { queryObject.setTimeout(sessionHolder.getTimeToLiveInSeconds()); } }
/** * Prepare the given Query object, applying cache settings and/or * a transaction timeout. * @param queryObject the Query object to prepare * @see #setCacheQueries * @see #setQueryCacheRegion */ @SuppressWarnings({"rawtypes", "deprecation"}) protected void prepareQuery(org.hibernate.Query queryObject) { if (isCacheQueries()) { queryObject.setCacheable(true); if (getQueryCacheRegion() != null) { queryObject.setCacheRegion(getQueryCacheRegion()); } } if (getFetchSize() > 0) { queryObject.setFetchSize(getFetchSize()); } if (getMaxResults() > 0) { queryObject.setMaxResults(getMaxResults()); } ResourceHolderSupport sessionHolder = (ResourceHolderSupport) TransactionSynchronizationManager.getResource(obtainSessionFactory()); if (sessionHolder != null && sessionHolder.hasTimeout()) { queryObject.setTimeout(sessionHolder.getTimeToLiveInSeconds()); } }
@Override protected void applyTimeout(int timeout) { query.setTimeout( timeout ); }
@Override public Query setTimeout(int i) { return query.setTimeout(i); }
public TypedQuery<T> setTimeout(int timeout) { query.setTimeout(timeout); return this; }
@Override public Query setTimeout(final int timeout) { return query.setTimeout(timeout); }
Query query = session.createQuery(someQueryString); query.setTimeout(theTimeOut);
/** * Apply the current transaction timeout, if any, to the given * Hibernate Query object. * @param query the Hibernate Query object * @param sessionFactory Hibernate SessionFactory that the Query was created for * (may be {@code null}) * @see org.hibernate.Query#setTimeout */ public static void applyTransactionTimeout(Query query, SessionFactory sessionFactory) { Assert.notNull(query, "No Query object specified"); if (sessionFactory != null) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); if (sessionHolder != null && sessionHolder.hasTimeout()) { query.setTimeout(sessionHolder.getTimeToLiveInSeconds()); } } }
q.setTimeout(timeoutParam.intValue());
query.setTimeout(timeout.intValue());
public Query setHint(String hintName, Object value) { try { if ( "org.hibernate.timeout".equals( hintName ) ) { query.setTimeout( ConfigurationHelper.getInteger( value ) );
public Query setHint(String hintName, Object value) { try { if ( "org.hibernate.timeout".equals( hintName ) ) { query.setTimeout( (Integer) value );
query.setTimeout(timeout);
private void initQuery(Query query, NamedQueryDefinition nqd) { query.setCacheable( nqd.isCacheable() ); query.setCacheRegion( nqd.getCacheRegion() ); if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() ); if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() ); if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() ); query.setReadOnly( nqd.isReadOnly() ); if ( nqd.getComment() != null ) query.setComment( nqd.getComment() ); }
private void initQuery(Query query, NamedQueryDefinition nqd) { query.setCacheable( nqd.isCacheable() ); query.setCacheRegion( nqd.getCacheRegion() ); if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() ); if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() ); if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() ); query.setReadOnly( nqd.isReadOnly() ); if ( nqd.getComment() != null ) query.setComment( nqd.getComment() ); }
private void initQuery(Query query, NamedQueryDefinition nqd) { query.setCacheable( nqd.isCacheable() ); query.setCacheRegion( nqd.getCacheRegion() ); if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() ); if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() ); if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() ); query.setReadOnly( nqd.isReadOnly() ); if ( nqd.getComment() != null ) query.setComment( nqd.getComment() ); }
public Query getNamedQuery(String queryName) throws MappingException { NamedQueryDefinition nqd = factory.getNamedQuery(queryName); final Query query; if ( nqd != null ) { query = createQuery( nqd.getQueryString(), nqd.getFlushMode() ); query.setComment("named HQL query " + queryName); } else { NamedSQLQueryDefinition nsqlqd = factory.getNamedSQLQuery( queryName ); if (nsqlqd==null) { throw new MappingException("Named query not known: " + queryName); } query = new SQLQueryImpl(nsqlqd, this); nqd = nsqlqd; query.setComment("named native SQL query " + queryName); } query.setCacheable( nqd.isCacheable() ); query.setCacheRegion( nqd.getCacheRegion() ); if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() ); if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() ); return query; }
query.setTimeout(timeout);
/** * Prepare the given Query object, applying cache settings and/or * a transaction timeout. * @param queryObject the Query object to prepare * @see #setCacheQueries * @see #setQueryCacheRegion */ protected void prepareQuery(Query queryObject) { if (isCacheQueries()) { queryObject.setCacheable(true); if (getQueryCacheRegion() != null) { queryObject.setCacheRegion(getQueryCacheRegion()); } } if (getFetchSize() > 0) { queryObject.setFetchSize(getFetchSize()); } if (getMaxResults() > 0) { queryObject.setMaxResults(getMaxResults()); } SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory()); if (sessionHolder != null && sessionHolder.hasTimeout()) { queryObject.setTimeout(sessionHolder.getTimeToLiveInSeconds()); } }