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


Java PersistentCollection类代码示例

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


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

示例1: execute

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
@Override
public void execute() throws HibernateException {
	// this method is called when a new non-null collection is persisted
	// or when an existing (non-null) collection is moved to a new owner
	final PersistentCollection collection = getCollection();
	
	preRecreate();
	getPersister().recreate( collection, getKey(), getSession() );
	getSession().getPersistenceContext().getCollectionEntry( collection ).afterAction( collection );
	evict();
	postRecreate();

	if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
		getSession().getFactory().getStatisticsImplementor().recreateCollection( getPersister().getRole() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:CollectionRecreateAction.java

示例2: evictCollection

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
public void evictCollection(Object value, CollectionType type) {

		final Object pc;
		if ( type.hasHolder() ) {
			pc = getSession().getPersistenceContext().removeCollectionHolder(value);
		}
		else if ( value instanceof PersistentCollection ) {
			pc = value;
		}
		else {
			return; //EARLY EXIT!
		}

		PersistentCollection collection = (PersistentCollection) pc;
		if ( collection.unsetSession( getSession() ) ) evictCollection(collection);
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:EvictVisitor.java

示例3: CollectionRemoveAction

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * Removes a persistent collection from its loaded owner.
 *
 * Use this constructor when the collection is non-null.
 *
 * @param collection The collection to to remove; must be non-null
 * @param persister  The collection's persister
 * @param id The collection key
 * @param emptySnapshot Indicates if the snapshot is empty
 * @param session The session
 *
 * @throws AssertionFailure if collection is null.
 */
public CollectionRemoveAction(
			final PersistentCollection collection,
			final CollectionPersister persister,
			final Serializable id,
			final boolean emptySnapshot,
			final SessionImplementor session) {
	super( persister, collection, id, session );
	if ( collection == null ) {
		throw new AssertionFailure("collection == null");
	}
	this.emptySnapshot = emptySnapshot;
	// the loaded owner will be set to null after the collection is removed,
	// so capture its value as the affected owner so it is accessible to
	// both pre- and post- events
	this.affectedOwner = session.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:CollectionRemoveAction.java

示例4: CollectionEntry

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * For collections just loaded from the database
 */
public CollectionEntry(
		final PersistentCollection collection,
		final CollectionPersister loadedPersister,
		final Serializable loadedKey,
		final boolean ignore
) {
	this.ignore=ignore;

	//collection.clearDirty()

	this.loadedKey = loadedKey;
	setLoadedPersister(loadedPersister);

	collection.setSnapshot(loadedKey, role, null);

	//postInitialize() will be called after initialization
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:CollectionEntry.java

示例5: execute

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
@Override
public void execute() throws HibernateException {
	preRemove();

	if ( !emptySnapshot ) {
		// an existing collection that was either non-empty or uninitialized
		// is replaced by null or a different collection
		// (if the collection is uninitialized, hibernate has no way of
		// knowing if the collection is actually empty without querying the db)
		getPersister().remove( getKey(), getSession() );
	}
	
	final PersistentCollection collection = getCollection();
	if ( collection != null ) {
		getSession().getPersistenceContext().getCollectionEntry( collection ).afterAction( collection );
	}

	evict();
	postRemove();

	if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
		getSession().getFactory().getStatisticsImplementor().removeCollection( getPersister().getRole() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:CollectionRemoveAction.java

示例6: processNeverReferencedCollection

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session)
		throws HibernateException {
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	final CollectionEntry entry = persistenceContext.getCollectionEntry( coll );

	if ( LOG.isDebugEnabled() ) {
		LOG.debugf(
				"Found collection with unloaded owner: %s",
				MessageHelper.collectionInfoString( 
						entry.getLoadedPersister(),
						coll,
						entry.getLoadedKey(),
						session
				)
		);
	}

	entry.setCurrentPersister( entry.getLoadedPersister() );
	entry.setCurrentKey( entry.getLoadedKey() );

	prepareCollectionForUpdate( coll, entry, session.getFactory() );

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Collections.java

示例7: addCollection

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * Add an collection to the cache, with a given collection entry.
 *
 * @param coll The collection for which we are adding an entry.
 * @param entry The entry representing the collection.
 * @param key The key of the collection's entry.
 */
private void addCollection(PersistentCollection coll, CollectionEntry entry, Serializable key) {
	collectionEntries.put( coll, entry );
	final CollectionKey collectionKey = new CollectionKey( entry.getLoadedPersister(), key );
	final PersistentCollection old = collectionsByKey.put( collectionKey, coll );
	if ( old != null ) {
		if ( old == coll ) {
			throw new AssertionFailure( "bug adding collection twice" );
		}
		// or should it actually throw an exception?
		old.unsetSession( session );
		collectionEntries.remove( old );
		// watch out for a case where old is still referenced
		// somewhere in the object graph! (which is a user error)
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:StatefulPersistenceContext.java

示例8: collectionInfoString

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * Generate an info message string relating to a particular managed
 * collection.  Attempts to intelligently handle property-refs issues
 * where the collection key is not the same as the owner key.
 *
 * @param persister The persister for the collection
 * @param collection The collection itself
 * @param collectionKey The collection key
 * @param session The session
 * @return An info string, in the form [Foo.bars#1]
 */
public static String collectionInfoString( 
		CollectionPersister persister,
		PersistentCollection collection,
		Serializable collectionKey,
		SessionImplementor session ) {
	
	StringBuilder s = new StringBuilder();
	s.append( '[' );
	if ( persister == null ) {
		s.append( "<unreferenced>" );
	}
	else {
		s.append( persister.getRole() );
		s.append( '#' );
		
		Type ownerIdentifierType = persister.getOwnerEntityPersister()
				.getIdentifierType();
		Serializable ownerKey;
		// TODO: Is it redundant to attempt to use the collectionKey,
		// or is always using the owner id sufficient?
		if ( collectionKey.getClass().isAssignableFrom( 
				ownerIdentifierType.getReturnedClass() ) ) {
			ownerKey = collectionKey;
		} else {
			ownerKey = session.getPersistenceContext()
					.getEntry( collection.getOwner() ).getId();
		}
		s.append( ownerIdentifierType.toLoggableString( 
				ownerKey, session.getFactory() ) );
	}
	s.append( ']' );

	return s.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:MessageHelper.java

示例9: PreCollectionRecreateEvent

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
public PreCollectionRecreateEvent(
		CollectionPersister collectionPersister,
		PersistentCollection collection,
		EventSource source) {
	super(
			collectionPersister,
			collection,
			source,
			collection.getOwner(),
			getOwnerIdOrNull( collection.getOwner(), source )
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:PreCollectionRecreateEvent.java

示例10: CollectionUpdateAction

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * Constructs a CollectionUpdateAction
 *
 * @param collection The collection to update
 * @param persister The collection persister
 * @param id The collection key
 * @param emptySnapshot Indicates if the snapshot is empty
 * @param session The session
 */
public CollectionUpdateAction(
			final PersistentCollection collection,
			final CollectionPersister persister,
			final Serializable id,
			final boolean emptySnapshot,
			final SessionImplementor session) {
	super( persister, collection, id, session );
	this.emptySnapshot = emptySnapshot;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:CollectionUpdateAction.java

示例11: processQueuedOps

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
@Override
public void processQueuedOps(PersistentCollection collection, Serializable key, SessionImplementor session)
		throws HibernateException {
	if ( collection.hasQueuedOperations() ) {
		doProcessQueuedOps( collection, key, session );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AbstractCollectionPersister.java

示例12: addBatchLoadableCollection

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * If an CollectionEntry represents a batch loadable collection, add
 * it to the queue.
 */
public void addBatchLoadableCollection(PersistentCollection collection, CollectionEntry ce) {
	final CollectionPersister persister = ce.getLoadedPersister();

	LinkedHashMap<CollectionEntry, PersistentCollection> map =  batchLoadableCollections.get( persister.getRole() );
	if ( map == null ) {
		map = new LinkedHashMap<CollectionEntry, PersistentCollection>( 16 );
		batchLoadableCollections.put( persister.getRole(), map );
	}
	map.put( ce, collection );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:BatchFetchQueue.java

示例13: isOwnerUnchanged

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * Has the owner of the collection changed since the collection
 * was snapshotted and detached?
 */
protected static boolean isOwnerUnchanged(
		final PersistentCollection snapshot, 
		final CollectionPersister persister, 
		final Serializable id
) {
	return isCollectionSnapshotValid(snapshot) &&
			persister.getRole().equals( snapshot.getRole() ) &&
			id.equals( snapshot.getKey() );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ProxyVisitor.java

示例14: dirty

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
/**
 * Determine if the collection is "really" dirty, by checking dirtiness
 * of the collection elements, if necessary
 */
private void dirty(PersistentCollection collection) throws HibernateException {

	boolean forceDirty = collection.wasInitialized() &&
			!collection.isDirty() && //optimization
			getLoadedPersister() != null &&
			getLoadedPersister().isMutable() && //optimization
			( collection.isDirectlyAccessible() || getLoadedPersister().getElementType().isMutable() ) && //optimization
			!collection.equalsSnapshot( getLoadedPersister() );

	if ( forceDirty ) {
		collection.dirty();
	}

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:CollectionEntry.java

示例15: preFlush

import org.hibernate.collection.spi.PersistentCollection; //导入依赖的package包/类
public void preFlush(PersistentCollection collection) throws HibernateException {
	if ( loadedKey == null && collection.getKey() != null ) {
		loadedKey = collection.getKey();
	}

	boolean nonMutableChange = collection.isDirty() &&
			getLoadedPersister()!=null &&
			!getLoadedPersister().isMutable();
	if (nonMutableChange) {
		throw new HibernateException(
				"changed an immutable collection instance: " +
				MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() )
			);
	}

	dirty(collection);

	if ( LOG.isDebugEnabled() && collection.isDirty() && getLoadedPersister() != null ) {
		LOG.debugf( "Collection dirty: %s",
				MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() ) );
	}

	setDoupdate(false);
	setDoremove(false);
	setDorecreate(false);
	setReached(false);
	setProcessed(false);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:CollectionEntry.java


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