當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。