Java 类javax.persistence.QueryHint 实例源码

项目: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()] ) );
}
项目:hyperjaxb3    文件:CreateXAnnotations.java   
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"),
        @QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH, value = "q.subquestions"),
        @QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH, value = "q.translations"),
        @QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH, value = "questionOptions.translations"),
        @QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH, value = "subquestions.translations"),
        @QueryHint(name = org.eclipse.persistence.config.QueryHints.BATCH, value = "subquestions.questionOptions"), }, forCounting = false)
List<Question> findInList(@Param("questionIds")
List<Integer> questionIds);
项目:deltaspike    文件:CdiQueryInvocationContext.java   
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;
}
项目:deltaspike    文件:CdiQueryInvocationContext.java   
private QueryHint[] extractQueryHints()
{
    org.apache.deltaspike.data.api.Query query = getRepositoryMethodMetadata().getQuery();        
    if (query != null && query.hints().length > 0)
    {
        return query.hints();
    }

    return null;
}
项目: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);
项目:score    文件:RunningExecutionPlanRepository.java   
@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 = "true")
, @QueryHint(name = "org.hibernate.cacheRegion", value = "omoikane.entities.Usuario") } )
@Query("SELECT COUNT(*) as count FROM Usuario u")
Long countIt();
项目:deltaspike    文件:SimpleIntermediateRepository.java   
@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   
/**
 * Retrieve users by their lastname. The finder {@literal User.findByLastname} is declared in
 * {@literal META-INF/orm.xml} .
 *
 * @param lastname
 * @return all users with the given lastname
 */
@QueryHints({@QueryHint(name = "foo", value = "bar")})
List<User> findByLastname(String lastname);