本文整理汇总了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;
}
示例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);
}
示例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...
}
}
}
示例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);
}