本文整理了Java中org.hibernate.Query.setTimeout
方法的一些代码示例,展示了Query.setTimeout
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setTimeout
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setTimeout
[英]Set a timeout for the underlying JDBC query.
[中]为基础JDBC查询设置超时。
代码示例来源:origin: spring-projects/spring-framework
/**
* 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());
}
}
代码示例来源:origin: org.springframework/spring-orm
/**
* 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());
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
@Override
protected void applyTimeout(int timeout) {
query.setTimeout( timeout );
}
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public Query setTimeout(int i) {
return query.setTimeout(i);
}
代码示例来源:origin: riotfamily/riot
public TypedQuery<T> setTimeout(int timeout) {
query.setTimeout(timeout);
return this;
}
代码示例来源:origin: ezbz/projectx
@Override
public Query setTimeout(final int timeout) {
return query.setTimeout(timeout);
}
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(someQueryString);
query.setTimeout(theTimeOut);
代码示例来源:origin: apache/servicemix-bundles
/**
* 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());
}
}
}
代码示例来源:origin: org.grails/grails-hibernate
q.setTimeout(timeoutParam.intValue());
代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate
query.setTimeout(timeout.intValue());
代码示例来源:origin: hibernate/hibernate-entitymanager
public Query setHint(String hintName, Object value) {
try {
if ( "org.hibernate.timeout".equals( hintName ) ) {
query.setTimeout( ConfigurationHelper.getInteger( value ) );
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
public Query setHint(String hintName, Object value) {
try {
if ( "org.hibernate.timeout".equals( hintName ) ) {
query.setTimeout( (Integer) value );
代码示例来源:origin: com.mysema.querydsl/querydsl-hql
query.setTimeout(timeout);
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
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() );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
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() );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
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() );
}
代码示例来源:origin: hibernate/hibernate
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;
}
代码示例来源:origin: com.querydsl/querydsl-jpa
query.setTimeout(timeout);
代码示例来源:origin: apache/servicemix-bundles
/**
* 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());
}
}
内容来源于网络,如有侵权,请联系作者删除!