本文整理匯總了Java中javax.persistence.TypedQuery.setHint方法的典型用法代碼示例。如果您正苦於以下問題:Java TypedQuery.setHint方法的具體用法?Java TypedQuery.setHint怎麽用?Java TypedQuery.setHint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.persistence.TypedQuery
的用法示例。
在下文中一共展示了TypedQuery.setHint方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
public List<Partij> get() {
final TypedQuery<Partij> query = em.createQuery("select p from Partij p where p.isActueelEnGeldig = true", Partij.class);
query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
query.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
return query.getResultList();
}
示例2: findCode
import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
public ConceptEntity findCode(String codeSystemUri, String code) {
ConceptEntity conceptEntity = null;
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<ConceptEntity> criteria = builder.createQuery(ConceptEntity.class);
Root<ConceptEntity> root = criteria.from(ConceptEntity.class);
List<Predicate> predList = new LinkedList<Predicate>();
List<ConceptEntity> results = new ArrayList<ConceptEntity>();
Join<ConceptEntity,CodeSystemRepository> join = root.join("codeSystemEntity");
log.debug("Looking for code ="+code+" in "+codeSystemUri);
Predicate pcode = builder.equal(root.get("code"), code);
predList.add(pcode);
Predicate psystem = builder.equal(join.get("codeSystemUri"), codeSystemUri);
predList.add(psystem);
Predicate[] predArray = new Predicate[predList.size()];
predList.toArray(predArray);
criteria.select(root).where(predArray);
TypedQuery<ConceptEntity> qry = em.createQuery(criteria);
qry.setHint("javax.persistence.cache.storeMode", "REFRESH");
List<ConceptEntity> qryResults = qry.getResultList();
for (ConceptEntity concept : qryResults) {
conceptEntity = concept;
log.debug("Found for code="+code+" ConceptEntity.Id="+conceptEntity.getId());
break;
}
return conceptEntity;
}
示例3: findCode
import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
public ConceptEntity findCode(Coding coding) {
ConceptEntity conceptEntity = null;
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<ConceptEntity> criteria = builder.createQuery(ConceptEntity.class);
Root<ConceptEntity> root = criteria.from(ConceptEntity.class);
List<Predicate> predList = new LinkedList<Predicate>();
List<ConceptEntity> results = new ArrayList<ConceptEntity>();
Join<ConceptEntity,CodeSystemRepository> join = root.join("codeSystemEntity");
log.debug("Looking for code ="+coding.getCode()+" in "+coding.getSystem());
Predicate pcode = builder.equal(root.get("code"), coding.getCode());
predList.add(pcode);
Predicate psystem = builder.equal(join.get("codeSystemUri"), coding.getSystem());
predList.add(psystem);
Predicate[] predArray = new Predicate[predList.size()];
predList.toArray(predArray);
criteria.select(root).where(predArray);
TypedQuery<ConceptEntity> qry = em.createQuery(criteria);
qry.setHint("javax.persistence.cache.storeMode", "REFRESH");
List<ConceptEntity> qryResults = qry.getResultList();
for (ConceptEntity concept : qryResults) {
conceptEntity = concept;
log.debug("Found for code="+coding.getCode()+" ConceptEntity.Id="+conceptEntity.getId());
break;
}
return conceptEntity;
}