本文整理汇总了Java中org.hibernate.persister.collection.CollectionPersister.getRole方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionPersister.getRole方法的具体用法?Java CollectionPersister.getRole怎么用?Java CollectionPersister.getRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.persister.collection.CollectionPersister
的用法示例。
在下文中一共展示了CollectionPersister.getRole方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CollectionKey
import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
public CollectionKey(CollectionPersister persister, Serializable key) {
this(
persister.getRole(),
key,
persister.getKeyType(),
persister.getOwnerEntityPersister().getEntityMetamodel().getEntityMode(),
persister.getFactory()
);
}
示例2: buildCacheKey
import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
private CacheKey buildCacheKey(Serializable ownerIdentifier, CollectionPersister p) {
return new CacheKey(
ownerIdentifier,
p.getKeyType(),
p.getRole(),
null, // have to assume non tenancy
sessionFactory
);
}
示例3: CollectionAction
import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
protected CollectionAction(
final CollectionPersister persister,
final PersistentCollection collection,
final Serializable key,
final SessionImplementor session) {
this.persister = persister;
this.session = session;
this.key = key;
this.collectionRole = persister.getRole();
this.collection = collection;
}
示例4: processDereferencedCollection
import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
private static void processDereferencedCollection(PersistentCollection coll, SessionImplementor session) {
final PersistenceContext persistenceContext = session.getPersistenceContext();
final CollectionEntry entry = persistenceContext.getCollectionEntry( coll );
final CollectionPersister loadedPersister = entry.getLoadedPersister();
if ( loadedPersister != null && LOG.isDebugEnabled() ) {
LOG.debugf(
"Collection dereferenced: %s",
MessageHelper.collectionInfoString( loadedPersister,
coll, entry.getLoadedKey(), session
)
);
}
// do a check
final boolean hasOrphanDelete = loadedPersister != null && loadedPersister.hasOrphanDelete();
if ( hasOrphanDelete ) {
Serializable ownerId = loadedPersister.getOwnerEntityPersister().getIdentifier( coll.getOwner(), session );
if ( ownerId == null ) {
// the owning entity may have been deleted and its identifier unset due to
// identifier-rollback; in which case, try to look up its identifier from
// the persistence context
if ( session.getFactory().getSettings().isIdentifierRollbackEnabled() ) {
final EntityEntry ownerEntry = persistenceContext.getEntry( coll.getOwner() );
if ( ownerEntry != null ) {
ownerId = ownerEntry.getId();
}
}
if ( ownerId == null ) {
throw new AssertionFailure( "Unable to determine collection owner identifier for orphan-delete processing" );
}
}
final EntityKey key = session.generateEntityKey( ownerId, loadedPersister.getOwnerEntityPersister() );
final Object owner = persistenceContext.getEntity( key );
if ( owner == null ) {
throw new AssertionFailure(
"collection owner not associated with session: " +
loadedPersister.getRole()
);
}
final EntityEntry e = persistenceContext.getEntry( owner );
//only collections belonging to deleted entities are allowed to be dereferenced in the case of orphan delete
if ( e != null && e.getStatus() != Status.DELETED && e.getStatus() != Status.GONE ) {
throw new HibernateException(
"A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance: " +
loadedPersister.getRole()
);
}
}
// do the work
entry.setCurrentPersister( null );
entry.setCurrentKey( null );
prepareCollectionForUpdate( coll, entry, session.getFactory() );
}
示例5: prepareCollectionForUpdate
import org.hibernate.persister.collection.CollectionPersister; //导入方法依赖的package包/类
/**
* 1. record the collection role that this collection is referenced by
* 2. decide if the collection needs deleting/creating/updating (but
* don't actually schedule the action yet)
*/
@SuppressWarnings( {"JavaDoc"})
private static void prepareCollectionForUpdate(
PersistentCollection collection,
CollectionEntry entry,
SessionFactoryImplementor factory) {
if ( entry.isProcessed() ) {
throw new AssertionFailure( "collection was processed twice by flush()" );
}
entry.setProcessed( true );
final CollectionPersister loadedPersister = entry.getLoadedPersister();
final CollectionPersister currentPersister = entry.getCurrentPersister();
if ( loadedPersister != null || currentPersister != null ) {
// it is or was referenced _somewhere_
// if either its role changed, or its key changed
final boolean ownerChanged = loadedPersister != currentPersister
|| !currentPersister.getKeyType().isEqual( entry.getLoadedKey(), entry.getCurrentKey(), factory );
if ( ownerChanged ) {
// do a check
final boolean orphanDeleteAndRoleChanged =
loadedPersister != null && currentPersister != null && loadedPersister.hasOrphanDelete();
if (orphanDeleteAndRoleChanged) {
throw new HibernateException(
"Don't change the reference to a collection with delete-orphan enabled : "
+ loadedPersister.getRole()
);
}
// do the work
if ( currentPersister != null ) {
entry.setDorecreate( true );
}
if ( loadedPersister != null ) {
// we will need to remove ye olde entries
entry.setDoremove( true );
if ( entry.isDorecreate() ) {
LOG.trace( "Forcing collection initialization" );
collection.forceInitialization();
}
}
}
else if ( collection.isDirty() ) {
// the collection's elements have changed
entry.setDoupdate( true );
}
}
}