项目:lams
文件:JPAOverriddenAnnotationReader.java
private static void buildQueryHints(List<Element> elements,AnnotationDescriptor ann){
List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
for ( Element hint : elements ) {
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
String value = hint.attributeValue( "name" );
if ( value == null ) {
throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
}
hintDescriptor.setValue( "name",value );
value = hint.attributeValue( "value" );
if ( value == null ) {
throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION );
}
hintDescriptor.setValue( "value",value );
queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
}
ann.setValue( "hints",queryHints.toArray( new QueryHint[queryHints.size()] ) );
}
public XAnnotation<javax.persistence.NamedQuery> createNamedQuery(
NamedQuery source) {
return source == null ? null :
//
new XAnnotation<javax.persistence.NamedQuery>(
javax.persistence.NamedQuery.class,//
AnnotationUtils.create("query",source.getQuery()),//
AnnotationUtils.create("hints",createqueryHint(source.getHint()),QueryHint.class),//
AnnotationUtils.create("name",source.getName()),AnnotationUtils.create("lockMode",createLockMode(source.getLockMode()))
//
);
}
项目:autodao
文件:DAOAnalysis.java
protected void addLockModeOps(InstructionList il,LockModeType lockMode,QueryHint[] hints) {
// setQueryHints()
processQueryHints(hints,il,TQ_CLASS);
// setLockMode()
if (lockMode != null && lockMode != LockModeType.NONE) {
ObjectType lm = new ObjectType("javax.persistence.LockModeType");
il.append(_factory.createFieldAccess(
"javax.persistence.LockModeType",lockMode.name(),lm,Constants.GETSTATIC));
il.append(_factory.createInvoke(TQ_CLASS,"setLockMode",new ObjectType(TQ_CLASS),new Type[] { lm },Constants.INVOKEINTERFACE));
}
}
项目:autodao
文件:DAOAnalysis.java
protected void processQueryHints(QueryHint[] hints,InstructionList il,String queryClass) {
for (QueryHint qh : hints) {
il.append(new PUSH(_cp,qh.name()));
il.append(new PUSH(_cp,qh.value()));
il.append(_factory.createInvoke(queryClass,"setQueryHint",new ObjectType(queryClass),new Type[] { Type.STRING,Type.OBJECT },Constants.INVOKEINTERFACE));
}
}
项目:gazpachoquest
文件:QuestionRepository.java
@Query("select q from Question q where q.id in :questionIds")
@QueryHints(value = { @QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH_TYPE,value = "IN"),@QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH,value = "q.questionoptions"),value = "q.subquestions"),value = "q.translations"),value = "questionoptions.translations"),value = "subquestions.translations"),value = "subquestions.questionoptions"),},forCounting = false)
List<Question> findInList(@Param("questionIds")
List<Integer> questionIds);
public Query applyRestrictions(Query query)
{
Parameters params = getParams();
Method method = getmethod();
if (params.hasSizeRestriction())
{
query.setMaxResults(params.getSizeRestriciton());
}
if (params.hasFirstResult())
{
query.setFirstResult(params.getFirstResult());
}
LockModeType lockMode = extractLockMode();
if (lockMode != null)
{
query.setLockMode(lockMode);
}
QueryHint[] hints = extractQueryHints();
if (hints != null)
{
for (QueryHint hint : hints)
{
query.setHint(hint.name(),hint.value());
}
}
applyEntityGraph(query,method);
query = applyJpaQueryPostProcessors(query);
return query;
}
项目:dpCms
文件:DictionaryRepository.java
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable",value ="true") })
public List<Dictionary> findByType(int type);
项目:iris
文件:RouteDataRevisionRepository.java
@QueryHints(value = @QueryHint(name = HINT_FETCH_SIZE,value = "1"))
@Query("SELECT r FROM RouteDataRevision r WHERE validFrom <= :date AND (validTo >= :date OR validTo IS NULL)")
Stream<RouteDataRevision> findValid(@Param("date") Date date);
项目:Spring-Data-JPA-Demo
文件:CountryRepository.java
@QueryHints(value = { @QueryHint (name = "org.hibernate.cacheable",value = "true")})
List<Country> findByPopulationGreaterThan(Integer population);
@Query("from RunningExecutionPlan r where r.flowUUID = :flowUUID")
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable",value ="true") })
public List<RunningExecutionPlan> findByUuidCached(@Param("flowUUID") String flowUUID);
项目:samplegwt
文件:PersonRepository.java
@QueryHints(value = { @QueryHint(name = "org.hibernate.readOnly",value = "true")})
Person findById(Long id);
项目:Omoikane
文件:UsuarioRepo.java
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable",value = "true"),@QueryHint(name = "org.hibernate.cacheRegion",value = "omoikane.entities.Usuario") } )
@Query("FROM Usuario u")
List<Usuario> findAll();
项目:Omoikane
文件:UsuarioRepo.java
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable",value = "omoikane.entities.Usuario") } )
@Query("SELECT COUNT(*) as count FROM Usuario u")
Long countIt();
@Query(hints = {
@QueryHint(name = "openjpa.hint.OptimizeResultCount",value = "some.invalid.value"),@QueryHint(name = "org.hibernate.comment",value = "I'm a little comment short and stout")
})
Simple findBy(Long id);
项目:spring-boot
文件:UserRepository.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。