本文整理汇总了Java中org.hibernate.type.CollectionType.UNFETCHED_COLLECTION属性的典型用法代码示例。如果您正苦于以下问题:Java CollectionType.UNFETCHED_COLLECTION属性的具体用法?Java CollectionType.UNFETCHED_COLLECTION怎么用?Java CollectionType.UNFETCHED_COLLECTION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.hibernate.type.CollectionType
的用法示例。
在下文中一共展示了CollectionType.UNFETCHED_COLLECTION属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCollection
@Override
Object processCollection(Object collection, CollectionType type) throws HibernateException {
if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
return null;
}
EventSource session = getSession();
CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
final Serializable collectionKey = extractCollectionKeyFromOwner( persister );
if ( collection!=null && (collection instanceof PersistentCollection) ) {
PersistentCollection wrapper = (PersistentCollection) collection;
if ( wrapper.setCurrentSession(session) ) {
//a "detached" collection!
if ( !isOwnerUnchanged( wrapper, persister, collectionKey ) ) {
// if the collection belonged to a different entity,
// clean up the existing state of the collection
removeCollection( persister, collectionKey, session );
}
reattachCollection(wrapper, type);
}
else {
// a collection loaded in the current session
// can not possibly be the collection belonging
// to the entity passed to update()
removeCollection(persister, collectionKey, session);
}
}
else {
// null or brand new collection
// this will also (inefficiently) handle arrays, which have
// no snapshot, so we can't do any better
removeCollection(persister, collectionKey, session);
}
return null;
}
示例2: processCollection
@Override
public Object processCollection(Object collection, CollectionType type) throws HibernateException {
if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
return null;
}
final EventSource session = getSession();
final CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
if ( isUpdate ) {
removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );
}
if ( collection != null && collection instanceof PersistentCollection ) {
final PersistentCollection wrapper = (PersistentCollection) collection;
wrapper.setCurrentSession( session );
if ( wrapper.wasInitialized() ) {
session.getPersistenceContext().addNewCollection( persister, wrapper );
}
else {
reattachCollection( wrapper, type );
}
}
else {
// otherwise a null or brand new collection
// this will also (inefficiently) handle arrays, which
// have no snapshot, so we can't do any better
//processArrayOrNewCollection(collection, type);
}
return null;
}
示例3: processCollection
/**
* {@inheritDoc}
*/
Object processCollection(Object collection, CollectionType type) throws HibernateException {
if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
return null;
}
EventSource session = getSession();
CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
final Serializable collectionKey = extractCollectionKeyFromOwner( persister );
if ( collection!=null && (collection instanceof PersistentCollection) ) {
PersistentCollection wrapper = (PersistentCollection) collection;
if ( wrapper.setCurrentSession(session) ) {
//a "detached" collection!
if ( !isOwnerUnchanged( wrapper, persister, collectionKey ) ) {
// if the collection belonged to a different entity,
// clean up the existing state of the collection
removeCollection( persister, collectionKey, session );
}
reattachCollection(wrapper, type);
}
else {
// a collection loaded in the current session
// can not possibly be the collection belonging
// to the entity passed to update()
removeCollection(persister, collectionKey, session);
}
}
else {
// null or brand new collection
// this will also (inefficiently) handle arrays, which have
// no snapshot, so we can't do any better
removeCollection(persister, collectionKey, session);
}
return null;
}
示例4: processArrayOrNewCollection
final Object processArrayOrNewCollection(Object collection, CollectionType collectionType)
throws HibernateException {
final SessionImplementor session = getSession();
if (collection==null) {
//do nothing
return null;
}
else {
CollectionPersister persister = session.getFactory().getCollectionPersister( collectionType.getRole() );
final PersistenceContext persistenceContext = session.getPersistenceContext();
//TODO: move into collection type, so we can use polymorphism!
if ( collectionType.hasHolder( session.getEntityMode() ) ) {
if (collection==CollectionType.UNFETCHED_COLLECTION) return null;
PersistentCollection ah = persistenceContext.getCollectionHolder(collection);
if (ah==null) {
ah = collectionType.wrap(session, collection);
persistenceContext.addNewCollection( persister, ah );
persistenceContext.addCollectionHolder(ah);
}
return null;
}
else {
PersistentCollection persistentCollection = collectionType.wrap(session, collection);
persistenceContext.addNewCollection( persister, persistentCollection );
if ( log.isTraceEnabled() ) log.trace( "Wrapped collection in role: " + collectionType.getRole() );
return persistentCollection; //Force a substitution!
}
}
}
示例5: processCollection
Object processCollection(Object collection, CollectionType type)
throws HibernateException {
if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
return null;
}
EventSource session = getSession();
CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
if ( isUpdate ) {
removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );
}
if ( collection != null && ( collection instanceof PersistentCollection ) ) {
PersistentCollection wrapper = ( PersistentCollection ) collection;
wrapper.setCurrentSession( session );
if ( wrapper.wasInitialized() ) {
session.getPersistenceContext().addNewCollection( persister, wrapper );
}
else {
reattachCollection( wrapper, type );
}
}
else {
// otherwise a null or brand new collection
// this will also (inefficiently) handle arrays, which
// have no snapshot, so we can't do any better
//processArrayOrNewCollection(collection, type);
}
return null;
}
示例6: processArrayOrNewCollection
final Object processArrayOrNewCollection(Object collection, CollectionType collectionType)
throws HibernateException {
final SessionImplementor session = getSession();
if ( collection == null ) {
//do nothing
return null;
}
else {
CollectionPersister persister = session.getFactory().getCollectionPersister( collectionType.getRole() );
final PersistenceContext persistenceContext = session.getPersistenceContext();
//TODO: move into collection type, so we can use polymorphism!
if ( collectionType.hasHolder() ) {
if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
return null;
}
PersistentCollection ah = persistenceContext.getCollectionHolder( collection );
if ( ah == null ) {
ah = collectionType.wrap( session, collection );
persistenceContext.addNewCollection( persister, ah );
persistenceContext.addCollectionHolder( ah );
}
return null;
}
else {
PersistentCollection persistentCollection = collectionType.wrap( session, collection );
persistenceContext.addNewCollection( persister, persistentCollection );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Wrapped collection in role: {0}", collectionType.getRole() );
}
return persistentCollection; //Force a substitution!
}
}
}
示例7: cascadeCollectionElements
/**
* Cascade to the collection elements
*/
private void cascadeCollectionElements(
final Object child,
final CollectionType collectionType,
final CascadeStyle style,
final Type elemType,
final Object anything,
final boolean isCascadeDeleteEnabled) throws HibernateException {
// we can't cascade to non-embedded elements
boolean embeddedElements = eventSource.getEntityMode()!=EntityMode.DOM4J ||
( (EntityType) collectionType.getElementType( eventSource.getFactory() ) ).isEmbeddedInXML();
boolean reallyDoCascade = style.reallyDoCascade(action) &&
embeddedElements && child!=CollectionType.UNFETCHED_COLLECTION;
if ( reallyDoCascade ) {
if ( log.isTraceEnabled() ) {
log.trace( "cascade " + action + " for collection: " + collectionType.getRole() );
}
Iterator iter = action.getCascadableChildrenIterator(eventSource, collectionType, child);
while ( iter.hasNext() ) {
cascadeProperty(
iter.next(),
elemType,
style,
anything,
isCascadeDeleteEnabled
);
}
if ( log.isTraceEnabled() ) {
log.trace( "done cascade " + action + " for collection: " + collectionType.getRole() );
}
}
final boolean deleteOrphans = style.hasOrphanDelete() &&
action.deleteOrphans() &&
elemType.isEntityType() &&
child instanceof PersistentCollection; //a newly instantiated collection can't have orphans
if ( deleteOrphans ) { // handle orphaned entities!!
if ( log.isTraceEnabled() ) {
log.trace( "deleting orphans for collection: " + collectionType.getRole() );
}
// we can do the cast since orphan-delete does not apply to:
// 1. newly instantiated collections
// 2. arrays (we can't track orphans for detached arrays)
final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() );
deleteOrphans( entityName, (PersistentCollection) child );
if ( log.isTraceEnabled() ) {
log.trace( "done deleting orphans for collection: " + collectionType.getRole() );
}
}
}