本文整理汇总了Java中javax.persistence.QueryHint类的典型用法代码示例。如果您正苦于以下问题:Java QueryHint类的具体用法?Java QueryHint怎么用?Java QueryHint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryHint类属于javax.persistence包,在下文中一共展示了QueryHint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildQueryHints
import javax.persistence.QueryHint; //导入依赖的package包/类
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()] ) );
}
示例2: createNamedQuery
import javax.persistence.QueryHint; //导入依赖的package包/类
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()))
//
);
}
示例3: addLockModeOps
import javax.persistence.QueryHint; //导入依赖的package包/类
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));
}
}
示例4: processQueryHints
import javax.persistence.QueryHint; //导入依赖的package包/类
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));
}
}
示例5: findInList
import javax.persistence.QueryHint; //导入依赖的package包/类
@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);
示例6: applyRestrictions
import javax.persistence.QueryHint; //导入依赖的package包/类
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;
}
示例7: extractQueryHints
import javax.persistence.QueryHint; //导入依赖的package包/类
private QueryHint[] extractQueryHints()
{
org.apache.deltaspike.data.api.Query query = getRepositoryMethodMetadata().getQuery();
if (query != null && query.hints().length > 0)
{
return query.hints();
}
return null;
}
示例8: findByType
import javax.persistence.QueryHint; //导入依赖的package包/类
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
public List<Dictionary> findByType(int type);
示例9: AND
import javax.persistence.QueryHint; //导入依赖的package包/类
@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);
示例10: findByPopulationGreaterThan
import javax.persistence.QueryHint; //导入依赖的package包/类
@QueryHints(value = { @QueryHint (name = "org.hibernate.cacheable", value = "true")})
List<Country> findByPopulationGreaterThan(Integer population);
示例11: findByUuidCached
import javax.persistence.QueryHint; //导入依赖的package包/类
@Query("from RunningExecutionPlan r where r.flowUUID = :flowUUID")
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
public List<RunningExecutionPlan> findByUuidCached(@Param("flowUUID") String flowUUID);
示例12: findById
import javax.persistence.QueryHint; //导入依赖的package包/类
@QueryHints(value = { @QueryHint(name = "org.hibernate.readOnly", value = "true")})
Person findById(Long id);
示例13: findAll
import javax.persistence.QueryHint; //导入依赖的package包/类
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true")
, @QueryHint(name = "org.hibernate.cacheRegion", value = "omoikane.entities.Usuario") } )
@Query("FROM Usuario u")
List<Usuario> findAll();
示例14: countIt
import javax.persistence.QueryHint; //导入依赖的package包/类
@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();
示例15: findBy
import javax.persistence.QueryHint; //导入依赖的package包/类
@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);