當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionFactoryImplementor.getEntityPersister方法代碼示例

本文整理匯總了Java中org.hibernate.engine.spi.SessionFactoryImplementor.getEntityPersister方法的典型用法代碼示例。如果您正苦於以下問題:Java SessionFactoryImplementor.getEntityPersister方法的具體用法?Java SessionFactoryImplementor.getEntityPersister怎麽用?Java SessionFactoryImplementor.getEntityPersister使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.engine.spi.SessionFactoryImplementor的用法示例。


在下文中一共展示了SessionFactoryImplementor.getEntityPersister方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQueryableCollection

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
protected QueryableCollection getQueryableCollection(
		String entityName,
		String propertyName,
		SessionFactoryImplementor factory) throws HibernateException {
	final PropertyMapping ownerMapping = (PropertyMapping) factory.getEntityPersister( entityName );
	final Type type = ownerMapping.toType( propertyName );
	if ( !type.isCollectionType() ) {
		throw new MappingException(
				"Property path [" + entityName + "." + propertyName + "] does not reference a collection"
		);
	}

	final String role = ( (CollectionType) type ).getRole();
	try {
		return (QueryableCollection) factory.getCollectionPersister( role );
	}
	catch ( ClassCastException cce ) {
		throw new QueryException( "collection role is not queryable: " + role );
	}
	catch ( Exception e ) {
		throw new QueryException( "collection role not found: " + role );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:AbstractEmptinessExpression.java

示例2: getSubclassEntityPersister

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
@Override
public EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory) {
	if ( !hasSubclasses() ) {
		return this;
	}
	else {
		final String concreteEntityName = getEntityTuplizer().determineConcreteSubclassEntityName(
				instance,
				factory
		);
		if ( concreteEntityName == null || getEntityName().equals( concreteEntityName ) ) {
			// the contract of EntityTuplizer.determineConcreteSubclassEntityName says that returning null
			// is an indication that the specified entity-name (this.getEntityName) should be used.
			return this;
		}
		else {
			return factory.getEntityPersister( concreteEntityName );
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:AbstractEntityPersister.java

示例3: toSqlString

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	final StringBuilder buf = new StringBuilder( toLeftSqlString( criteria, criteriaQuery ) );
	if ( op != null ) {
		buf.append( ' ' ).append( op ).append( ' ' );
	}
	if ( quantifier != null ) {
		buf.append( quantifier ).append( ' ' );
	}

	final SessionFactoryImplementor factory = criteriaQuery.getFactory();
	final OuterJoinLoadable persister =
			(OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );

	createAndSetInnerQuery( criteriaQuery, factory );
	criteriaImpl.setSession( deriveRootSession( criteria ) );

	final CriteriaJoinWalker walker = new CriteriaJoinWalker(
			persister,
			innerQuery,
			factory,
			criteriaImpl,
			criteriaImpl.getEntityOrClassName(),
			criteriaImpl.getSession().getLoadQueryInfluencers(),
			innerQuery.getRootSQLALias()
	);

	return buf.append( '(' ).append( walker.getSQLString() ).append( ')' ).toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:SubqueryExpression.java

示例4: destructure

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
@Override
public Object destructure(Object structured, SessionFactoryImplementor factory) {
	final Map map = (Map) structured;
	final boolean lazyPropertiesUnfetched = (Boolean) map.get( "_lazyPropertiesUnfetched" );
	final String subclass = (String) map.get( "_subclass" );
	final Object version = map.get( "_version" );
	final EntityPersister subclassPersister = factory.getEntityPersister( subclass );
	final String[] names = subclassPersister.getPropertyNames();
	final Serializable[] state = new Serializable[names.length];
	for ( int i = 0; i < names.length; i++ ) {
		state[i] = (Serializable) map.get( names[i] );
	}
	return new StandardCacheEntryImpl( state, subclass, lazyPropertiesUnfetched, version );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:StructuredCacheEntry.java

示例5: findQueryableUsingImports

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
/**
 * Given a (potentially unqualified) class name, locate its persister.
 *
 * @param sfi The session factory implementor.
 * @param className The (potentially unqualified) class name.
 *
 * @return The defined persister for this class, or null if none found.
 */
public static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi, String className) {
	final String importedClassName = sfi.getImportedClassName( className );
	if ( importedClassName == null ) {
		return null;
	}
	try {
		return (Queryable) sfi.getEntityPersister( importedClassName );
	}
	catch ( MappingException me ) {
		return null;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:SessionFactoryHelper.java

示例6: BulkOperationCleanupAction

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
/**
 * Constructs an action to cleanup "affected cache regions" based on a
 * set of affected table spaces.  This differs from {@link #BulkOperationCleanupAction(SessionImplementor, Queryable[])}
 * in that here we have the affected <strong>table names</strong>.  From those
 * we deduce the entity persisters which are affected based on the defined
 * {@link EntityPersister#getQuerySpaces() table spaces}; and from there, we
 * determine the affected collection regions based on any collections
 * in which those entity persisters participate as elements/keys/etc.
 *
 * @param session The session to which this request is tied.
 * @param tableSpaces The table spaces.
 */
@SuppressWarnings({ "unchecked" })
public BulkOperationCleanupAction(SessionImplementor session, Set tableSpaces) {
	final LinkedHashSet<String> spacesList = new LinkedHashSet<String>();
	spacesList.addAll( tableSpaces );

	final SessionFactoryImplementor factory = session.getFactory();
	for ( String entityName : factory.getAllClassMetadata().keySet() ) {
		final EntityPersister persister = factory.getEntityPersister( entityName );
		final String[] entitySpaces = (String[]) persister.getQuerySpaces();
		if ( affectedEntity( tableSpaces, entitySpaces ) ) {
			spacesList.addAll( Arrays.asList( entitySpaces ) );

			if ( persister.hasCache() ) {
				entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrategy() ) );
			}
			if ( persister.hasNaturalIdentifier() && persister.hasNaturalIdCache() ) {
				naturalIdCleanups.add( new NaturalIdCleanup( persister.getNaturalIdCacheAccessStrategy() ) );
			}

			final Set<String> roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
			if ( roles != null ) {
				for ( String role : roles ) {
					final CollectionPersister collectionPersister = factory.getCollectionPersister( role );
					if ( collectionPersister.hasCache() ) {
						collectionCleanups.add(
								new CollectionCleanup( collectionPersister.getCacheAccessStrategy() )
						);
					}
				}
			}
		}
	}

	this.affectedTableSpaces = spacesList.toArray( new String[ spacesList.size() ] );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:48,代碼來源:BulkOperationCleanupAction.java

示例7: getAssociatedEntityPersister

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
protected EntityPersister getAssociatedEntityPersister(final SessionFactoryImplementor factory) {
	final EntityPersister persister = associatedEntityPersister;
	//The following branch implements a simple lazy-initialization, but rather than the canonical
	//form it returns the local variable to avoid a second volatile read: associatedEntityPersister
	//needs to be volatile as the initialization might happen by a different thread than the readers.
	if ( persister == null ) {
		associatedEntityPersister = factory.getEntityPersister( getAssociatedEntityName() );
		return associatedEntityPersister;
	}
	else {
		return persister;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:EntityType.java

示例8: loadByUniqueKey

import org.hibernate.engine.spi.SessionFactoryImplementor; //導入方法依賴的package包/類
/**
 * Load an instance by a unique key that is not the primary key.
 *
 * @param entityName The name of the entity to load
 * @param uniqueKeyPropertyName The name of the property defining the uniqie key.
 * @param key The unique key property value.
 * @param session The originating session.
 * @return The loaded entity
 * @throws HibernateException generally indicates problems performing the load.
 */
public Object loadByUniqueKey(
		String entityName, 
		String uniqueKeyPropertyName, 
		Object key, 
		SessionImplementor session) throws HibernateException {
	final SessionFactoryImplementor factory = session.getFactory();
	UniqueKeyLoadable persister = ( UniqueKeyLoadable ) factory.getEntityPersister( entityName );

	//TODO: implement caching?! proxies?!

	EntityUniqueKey euk = new EntityUniqueKey(
			entityName, 
			uniqueKeyPropertyName, 
			key, 
			getIdentifierOrUniqueKeyType( factory ),
			persister.getEntityMode(),
			session.getFactory()
	);

	final PersistenceContext persistenceContext = session.getPersistenceContext();
	Object result = persistenceContext.getEntity( euk );
	if ( result == null ) {
		result = persister.loadByUniqueKey( uniqueKeyPropertyName, key, session );
	}
	return result == null ? null : persistenceContext.proxyFor( result );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:37,代碼來源:EntityType.java


注:本文中的org.hibernate.engine.spi.SessionFactoryImplementor.getEntityPersister方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。