当前位置: 首页>>代码示例>>Java>>正文


Java Query.setHint方法代码示例

本文整理汇总了Java中javax.persistence.Query.setHint方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setHint方法的具体用法?Java Query.setHint怎么用?Java Query.setHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.persistence.Query的用法示例。


在下文中一共展示了Query.setHint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupQuery

import javax.persistence.Query; //导入方法依赖的package包/类
protected Query setupQuery(Query typedQuery) {
	// apply graph control
	if (!fetchPaths.isEmpty()) {
		applyFetchPaths(typedQuery);
	}

	// control Hibernate query caching
	if (cached) {
		typedQuery.setHint("org.hibernate.cacheable", Boolean.TRUE);
	}

	if (limit > 0) {
		typedQuery.setMaxResults(limit);
	}
	typedQuery.setFirstResult(offset);
	return typedQuery;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:18,代码来源:AbstractQueryExecutorImpl.java

示例2: build

import javax.persistence.Query; //导入方法依赖的package包/类
@Override
public <T> void build(EntityManager em, Query criteriaQuery, Class<T> entityClass,
					  Set<MetaAttributePath> fetchPaths) {
	EntityGraph<T> graph = em.createEntityGraph(entityClass);
	for (MetaAttributePath fetchPath : fetchPaths) {
		applyFetchPaths(graph, fetchPath);
	}
	criteriaQuery.setHint("javax.persistence.fetchgraph", graph);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:10,代码来源:EntityGraphBuilderImpl.java

示例3: applyTransactionTimeout

import javax.persistence.Query; //导入方法依赖的package包/类
/**
 * Apply the current transaction timeout, if any, to the given JPA Query object.
 * <p>This method sets the JPA 2.0 query hint "javax.persistence.query.timeout" accordingly.
 * @param query the JPA Query object
 * @param emf JPA EntityManagerFactory that the Query was created for
 */
public static void applyTransactionTimeout(Query query, EntityManagerFactory emf) {
	EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf);
	if (emHolder != null && emHolder.hasTimeout()) {
		int timeoutValue = (int) emHolder.getTimeToLiveInMillis();
		try {
			query.setHint("javax.persistence.query.timeout", timeoutValue);
		}
		catch (IllegalArgumentException ex) {
			// oh well, at least we tried...
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:EntityManagerFactoryUtils.java

示例4: zetDefaults

import javax.persistence.Query; //导入方法依赖的package包/类
private void zetDefaults(final Query query) {
    final Calendar cal = Calendar.getInstance();
    final int maandenTerug = -DATUM_EINDE_TERUG_MAAND;
    cal.add(Calendar.MONTH, maandenTerug);
    final Integer waarde = DatumUtil.vanDatumNaarInteger(cal.getTime());
    query.setParameter("dateinde", waarde);
    query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
    query.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:10,代码来源:LeveringsautorisatieRepositoryImpl.java


注:本文中的javax.persistence.Query.setHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。