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


Java SessionImplementor.getEntityMode方法代码示例

本文整理汇总了Java中org.hibernate.engine.SessionImplementor.getEntityMode方法的典型用法代码示例。如果您正苦于以下问题:Java SessionImplementor.getEntityMode方法的具体用法?Java SessionImplementor.getEntityMode怎么用?Java SessionImplementor.getEntityMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.engine.SessionImplementor的用法示例。


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

示例1: getOptionalObjectKey

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
private static EntityKey getOptionalObjectKey(QueryParameters queryParameters, SessionImplementor session) {
	final Object optionalObject = queryParameters.getOptionalObject();
	final Serializable optionalId = queryParameters.getOptionalId();
	final String optionalEntityName = queryParameters.getOptionalEntityName();

	if ( optionalObject != null && optionalEntityName != null ) {
		return new EntityKey( 
				optionalId,
				session.getEntityPersister( optionalEntityName, optionalObject ), 
				session.getEntityMode()
			);
	}
	else {
		return null;
	}

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:Loader.java

示例2: getKeyFromResultSet

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
/**
 * Read a row of <tt>Key</tt>s from the <tt>ResultSet</tt> into the given array.
 * Warning: this method is side-effecty.
 * <p/>
 * If an <tt>id</tt> is given, don't bother going to the <tt>ResultSet</tt>.
 */
private EntityKey getKeyFromResultSet(
        final int i,
        final Loadable persister,
        final Serializable id,
        final ResultSet rs,
        final SessionImplementor session) throws HibernateException, SQLException {

	Serializable resultId;

	// if we know there is exactly 1 row, we can skip.
	// it would be great if we could _always_ skip this;
	// it is a problem for <key-many-to-one>

	if ( isSingleRowLoader() && id != null ) {
		resultId = id;
	}
	else {
		
		Type idType = persister.getIdentifierType();
		resultId = (Serializable) idType.nullSafeGet(
				rs,
				getEntityAliases()[i].getSuffixedKeyAliases(),
				session,
				null //problematic for <key-many-to-one>!
			);
		
		final boolean idIsResultId = id != null && 
				resultId != null && 
				idType.isEqual( id, resultId, session.getEntityMode(), factory );
		
		if ( idIsResultId ) resultId = id; //use the id passed in
	}

	return resultId == null ?
			null :
			new EntityKey( resultId, persister, session.getEntityMode() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:44,代码来源:Loader.java

示例3: getCollection

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
/**
 * instantiate a collection wrapper (called when loading an object)
 *
 * @param key The collection owner key
 * @param session The session from which the request is originating.
 * @param owner The collection owner
 * @return The collection
 */
public Object getCollection(Serializable key, SessionImplementor session, Object owner) {

	CollectionPersister persister = getPersister( session );
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	final EntityMode entityMode = session.getEntityMode();

	if (entityMode==EntityMode.DOM4J && !isEmbeddedInXML) {
		return UNFETCHED_COLLECTION;
	}

	// check if collection is currently being loaded
	PersistentCollection collection = persistenceContext.getLoadContexts().locateLoadingCollection( persister, key );
	if ( collection == null ) {
		// check if it is already completely loaded, but unowned
		collection = persistenceContext.useUnownedCollection( new CollectionKey(persister, key, entityMode) );
		if ( collection == null ) {
			// create a new collection wrapper, to be initialized later
			collection = instantiate( session, persister, key );
			collection.setOwner( owner );

			persistenceContext.addUninitializedCollection( persister, collection, key );

			// some collections are not lazy:
			if ( initializeImmediately( entityMode ) ) {
				session.initializeCollection( collection, false );
			}
			else if ( !persister.isLazy() ) {
				persistenceContext.addNonLazyCollection( collection );
			}

			if ( hasHolder( entityMode ) ) {
				session.getPersistenceContext().addCollectionHolder( collection );
			}
		}
	}
	collection.setOwner( owner );
	return collection.getValue();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:47,代码来源:CollectionType.java

示例4: initializeLazyProperty

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public Object initializeLazyProperty(String fieldName, Object entity, SessionImplementor session)
		throws HibernateException {

	final Serializable id = session.getContextEntityIdentifier( entity );

	final EntityEntry entry = session.getPersistenceContext().getEntry( entity );
	if ( entry == null ) {
		throw new HibernateException( "entity is not associated with the session: " + id );
	}

	if ( log.isTraceEnabled() ) {
		log.trace(
				"initializing lazy properties of: " +
				MessageHelper.infoString( this, id, getFactory() ) +
				", field access: " + fieldName
			);
	}

	if ( hasCache() ) {
		CacheKey cacheKey = new CacheKey(id, getIdentifierType(), getEntityName(), session.getEntityMode(), getFactory() );
		Object ce = getCache().get( cacheKey, session.getTimestamp() );
		if (ce!=null) {
			CacheEntry cacheEntry = (CacheEntry) getCacheEntryStructure().destructure(ce, factory);
			if ( !cacheEntry.areLazyPropertiesUnfetched() ) {
				//note early exit here:
				return initializeLazyPropertiesFromCache( fieldName, entity, session, entry, cacheEntry );
			}
		}
	}

	return initializeLazyPropertiesFromDatastore( fieldName, entity, session, id, entry );

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:34,代码来源:AbstractEntityPersister.java

示例5: wrap

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentListElementHolder( session, (Element) collection );
	}
	else {
		return new PersistentList( session, (List) collection );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:ListType.java

示例6: wrap

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		throw new IllegalStateException("dom4j not supported");
	}
	else {
		return new PersistentMyList( session, (IMyList) collection );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:MyListType.java

示例7: getImplementation

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
/**
 * Return the underlying persistent object in the given <tt>Session</tt>, or null,
 * do not initialize the proxy
 */
public final Object getImplementation(SessionImplementor s) throws HibernateException {
	final EntityKey entityKey = new EntityKey(
			getIdentifier(),
			s.getFactory().getEntityPersister( getEntityName() ),
			s.getEntityMode()
		);
	return s.getPersistenceContext().getEntity( entityKey );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:AbstractLazyInitializer.java

示例8: wrap

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentElementHolder( session, (Element) collection );
	}
	else {
		return new PersistentSortedSet( session, (java.util.SortedSet) collection );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:SortedSetType.java

示例9: postFlush

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
/**
 * 1. Recreate the collection key -> collection map
 * 2. rebuild the collection entries
 * 3. call Interceptor.postFlush()
 */
protected void postFlush(SessionImplementor session) throws HibernateException {

	log.trace( "post flush" );

	final PersistenceContext persistenceContext = session.getPersistenceContext();
	persistenceContext.getCollectionsByKey().clear();
	persistenceContext.getBatchFetchQueue()
			.clearSubselects(); //the database has changed now, so the subselect results need to be invalidated

	Iterator iter = persistenceContext.getCollectionEntries().entrySet().iterator();
	while ( iter.hasNext() ) {
		Map.Entry me = (Map.Entry) iter.next();
		CollectionEntry collectionEntry = (CollectionEntry) me.getValue();
		PersistentCollection persistentCollection = (PersistentCollection) me.getKey();
		collectionEntry.postFlush(persistentCollection);
		if ( collectionEntry.getLoadedPersister() == null ) {
			//if the collection is dereferenced, remove from the session cache
			//iter.remove(); //does not work, since the entrySet is not backed by the set
			persistenceContext.getCollectionEntries()
					.remove(persistentCollection);
		}
		else {
			//otherwise recreate the mapping between the collection and its key
			CollectionKey collectionKey = new CollectionKey( 
					collectionEntry.getLoadedPersister(), 
					collectionEntry.getLoadedKey(), 
					session.getEntityMode() 
				);
			persistenceContext.getCollectionsByKey()
					.put(collectionKey, persistentCollection);
		}
	}
	
	session.getInterceptor().postFlush( new LazyIterator( persistenceContext.getEntitiesByKey() ) );

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:42,代码来源:AbstractFlushingEventListener.java

示例10: execute

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public void execute() throws HibernateException {
		EntityPersister persister = getPersister();
		SessionImplementor session = getSession();
		Object instance = getInstance();
		Serializable id = getId();

		boolean veto = preInsert();

		// Don't need to lock the cache here, since if someone
		// else inserted the same pk first, the insert would fail

		if ( !veto ) {
			
			persister.insert( id, state, instance, session );
		
			EntityEntry entry = session.getPersistenceContext().getEntry( instance );
			if ( entry == null ) {
				throw new AssertionFailure( "possible nonthreadsafe access to session" );
			}
			
			entry.postInsert();
	
			if ( persister.hasInsertGeneratedProperties() ) {
				persister.processInsertGeneratedProperties( id, instance, state, session );
				if ( persister.isVersionPropertyGenerated() ) {
					version = Versioning.getVersion(state, persister);
				}
				entry.postUpdate(instance, state, version);
			}
			
		}

		final SessionFactoryImplementor factory = getSession().getFactory();

		if ( isCachePutEnabled( persister, session ) ) {
			
			CacheEntry ce = new CacheEntry(
					state,
					persister, 
					persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
					version,
					session,
					instance
				);
			
			cacheEntry = persister.getCacheEntryStructure().structure(ce);
			final CacheKey ck = new CacheKey( 
					id, 
					persister.getIdentifierType(), 
					persister.getRootEntityName(), 
					session.getEntityMode(), 
					session.getFactory() 
				);
//			boolean put = persister.getCache().insert(ck, cacheEntry);
			boolean put = persister.getCache().insert( ck, cacheEntry, version );
			
			if ( put && factory.getStatistics().isStatisticsEnabled() ) {
				factory.getStatisticsImplementor()
						.secondLevelCachePut( getPersister().getCache().getRegionName() );
			}
			
		}

		postInsert();

		if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
			factory.getStatisticsImplementor()
					.insertEntity( getPersister().getEntityName() );
		}

	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:72,代码来源:EntityInsertAction.java

示例11: instantiate

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key)
throws HibernateException {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentElementHolder(session, persister, key);
	}
	else {
		return new PersistentBag(session);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:10,代码来源:BagType.java

示例12: wrap

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
@Override
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	if ( session.getEntityMode() == org.hibernate.EntityMode.DOM4J ) {
		throw new IllegalStateException("dom4j not supported");
	}
	else {
		return new utils.PersistentOwnedList( session, (java.util.List) collection );
	}
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:10,代码来源:AbastractOwnedListType.java

示例13: scheduleBatchLoadIfNeeded

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
/**
 * Register the entity as batch loadable, if enabled
 */
private void scheduleBatchLoadIfNeeded(
		Serializable id,
		SessionImplementor session) throws MappingException {
	//cannot batch fetch by unique key (property-ref associations)
	if ( uniqueKeyPropertyName == null && id != null ) {
		EntityPersister persister = session.getFactory().getEntityPersister( getAssociatedEntityName() );
		EntityKey entityKey = new EntityKey( id, persister, session.getEntityMode() );
		if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
			session.getPersistenceContext()
					.getBatchFetchQueue()
					.addBatchLoadableEntityKey( entityKey );
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:ManyToOneType.java

示例14: wrap

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentElementHolder( session, (Element) collection );
	}
	else {
		return new PersistentSet( session, (java.util.Set) collection );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:SetType.java

示例15: instantiate

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentListElementHolder(session, persister, key);
	}
	else {
		return new PersistentList(session);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:ListType.java


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