当前位置: 首页>>代码示例>>Java>>正文


Java NamedQuery类代码示例

本文整理汇总了Java中javax.persistence.NamedQuery的典型用法代码示例。如果您正苦于以下问题:Java NamedQuery类的具体用法?Java NamedQuery怎么用?Java NamedQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NamedQuery类属于javax.persistence包,在下文中一共展示了NamedQuery类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNamedQueries

import javax.persistence.NamedQuery; //导入依赖的package包/类
private NamedQueries getNamedQueries(Element tree, XMLContext.Default defaults) {
	//TODO avoid the Proxy Creation (@NamedQueries) when possible
	List<NamedQuery> queries = (List<NamedQuery>) buildNamedQueries( tree, false, defaults );
	if ( defaults.canUseJavaAnnotations() ) {
		NamedQuery annotation = getPhysicalAnnotation( NamedQuery.class );
		addNamedQueryIfNeeded( annotation, queries );
		NamedQueries annotations = getPhysicalAnnotation( NamedQueries.class );
		if ( annotations != null ) {
			for ( NamedQuery current : annotations.value() ) {
				addNamedQueryIfNeeded( current, queries );
			}
		}
	}
	if ( queries.size() > 0 ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( NamedQueries.class );
		ad.setValue( "value", queries.toArray( new NamedQuery[queries.size()] ) );
		return AnnotationFactory.create( ad );
	}
	else {
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:JPAOverriddenAnnotationReader.java

示例2: addNamedQueryIfNeeded

import javax.persistence.NamedQuery; //导入依赖的package包/类
private void addNamedQueryIfNeeded(NamedQuery annotation, List<NamedQuery> queries) {
	if ( annotation != null ) {
		String queryName = annotation.name();
		boolean present = false;
		for ( NamedQuery current : queries ) {
			if ( current.name().equals( queryName ) ) {
				present = true;
				break;
			}
		}
		if ( !present ) {
			queries.add( annotation );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:JPAOverriddenAnnotationReader.java

示例3: determineLockOptions

import javax.persistence.NamedQuery; //导入依赖的package包/类
public LockOptions determineLockOptions(NamedQuery namedQueryAnnotation) {
	LockModeType lockModeType = namedQueryAnnotation.lockMode();
	Integer lockTimeoutHint = getInteger( namedQueryAnnotation.name(), "javax.persistence.lock.timeout" );

	LockOptions lockOptions = new LockOptions( LockModeConverter.convertToLockMode( lockModeType ) );
	if ( lockTimeoutHint != null ) {
		lockOptions.setTimeOut( lockTimeoutHint );
	}

	return lockOptions;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:QueryHintDefinition.java

示例4: bindQuery

import javax.persistence.NamedQuery; //导入依赖的package包/类
public static void bindQuery(NamedQuery queryAnn, Mappings mappings, boolean isDefault) {
	if ( queryAnn == null ) return;
	if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) {
		throw new AnnotationException( "A named query must have a name when used in class or package level" );
	}
	//EJBQL Query
	QueryHintDefinition hints = new QueryHintDefinition( queryAnn.hints() );
	String queryName = queryAnn.query();
	NamedQueryDefinition queryDefinition = new NamedQueryDefinitionBuilder( queryAnn.name() )
			.setLockOptions( hints.determineLockOptions( queryAnn ) )
			.setQuery( queryName )
			.setCacheable( hints.getBoolean( queryName, QueryHints.CACHEABLE ) )
			.setCacheRegion( hints.getString( queryName, QueryHints.CACHE_REGION ) )
			.setTimeout( hints.getTimeout( queryName ) )
			.setFetchSize( hints.getInteger( queryName, QueryHints.FETCH_SIZE ) )
			.setFlushMode( hints.getFlushMode( queryName ) )
			.setCacheMode( hints.getCacheMode( queryName ) )
			.setReadOnly( hints.getBoolean( queryName, QueryHints.READ_ONLY ) )
			.setComment( hints.getString( queryName, QueryHints.COMMENT ) )
			.setParameterTypes( null )
			.createNamedQueryDefinition();

	if ( isDefault ) {
		mappings.addDefaultQuery( queryDefinition.getName(), queryDefinition );
	}
	else {
		mappings.addQuery( queryDefinition.getName(), queryDefinition );
	}
	if ( LOG.isDebugEnabled() ) {
		LOG.debugf( "Binding named query: %s => %s", queryDefinition.getName(), queryDefinition.getQueryString() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:QueryBinder.java

示例5: createNamedQuery

import javax.persistence.NamedQuery; //导入依赖的package包/类
public Object createNamedQuery(Objectref objRef) {
	String namedQuery = getStringFromObjectref(objRef);
	for(Class<?> entityClass : managedEntityClasses) {
		if(entityClass.isAnnotationPresent(NamedQuery.class)) {
			if(entityClass.getAnnotation(NamedQuery.class).name().equals(namedQuery)) {
				String jpqlQueryString = entityClass.getAnnotation(NamedQuery.class).query();
				return hqlAnalyzer.getQLSelectStatement(jpqlQueryString, null);
			}
		}
	}
	return null;
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:13,代码来源:MugglEntityManager.java

示例6: testEntityAnnotation

import javax.persistence.NamedQuery; //导入依赖的package包/类
public void testEntityAnnotation() throws Exception {

		Assert.assertNotNull(IssueHJIII100Type.class
				.getAnnotation(NamedQuery.class));

		Assert.assertEquals(
				1,
				IssueHJIII100Type.class.getAnnotation(NamedQuery.class).hints().length);
	}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:10,代码来源:IssueHJIII100Test.java

示例7: getQueryString

import javax.persistence.NamedQuery; //导入依赖的package包/类
public String getQueryString(String namedQueryName) {
	NamedQueries namedQueries = (NamedQueries) entityClass.getAnnotation(NamedQueries.class);
	for (NamedQuery namedQuery : namedQueries.value()) {
		if (namedQuery.name().equals(namedQueryName)) return namedQuery.query();
	}
	throw new QueryException("Named query " + namedQueryName + " not found in class " + entityClass.getName());
}
 
开发者ID:ivmarcos,项目名称:query,代码行数:8,代码来源:Reflection.java

示例8: bindQueries

import javax.persistence.NamedQuery; //导入依赖的package包/类
public static void bindQueries(NamedQueries queriesAnn, Mappings mappings, boolean isDefault) {
	if ( queriesAnn == null ) return;
	for (NamedQuery q : queriesAnn.value()) {
		bindQuery( q, mappings, isDefault );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:QueryBinder.java


注:本文中的javax.persistence.NamedQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。