WrapVisitorpublic class WrapVisitor extends ProxyVisitor Wrap collections in a Hibernate collection
wrapper. |
Fields Summary |
---|
private static final Log | log | boolean | substitute |
Methods Summary |
---|
boolean | isSubstitutionRequired()
return substitute;
| void | process(java.lang.Object object, org.hibernate.persister.entity.EntityPersister persister)
EntityMode entityMode = getSession().getEntityMode();
Object[] values = persister.getPropertyValues( object, entityMode );
Type[] types = persister.getPropertyTypes();
processEntityPropertyValues(values, types);
if ( isSubstitutionRequired() ) {
persister.setPropertyValues( object, values, entityMode );
}
| final java.lang.Object | processArrayOrNewCollection(java.lang.Object collection, org.hibernate.type.CollectionType collectionType)
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!
}
}
| java.lang.Object | processCollection(java.lang.Object collection, org.hibernate.type.CollectionType collectionType)
if ( collection!=null && (collection instanceof PersistentCollection) ) {
final SessionImplementor session = getSession();
PersistentCollection coll = (PersistentCollection) collection;
if ( coll.setCurrentSession(session) ) {
reattachCollection( coll, collectionType );
}
return null;
}
else {
return processArrayOrNewCollection(collection, collectionType);
}
| java.lang.Object | processComponent(java.lang.Object component, org.hibernate.type.AbstractComponentType componentType)
if (component!=null) {
Object[] values = componentType.getPropertyValues( component, getSession() );
Type[] types = componentType.getSubtypes();
boolean substituteComponent = false;
for ( int i=0; i<types.length; i++ ) {
Object result = processValue( values[i], types[i] );
if (result!=null) {
values[i] = result;
substituteComponent = true;
}
}
if (substituteComponent) {
componentType.setPropertyValues( component, values, getSession().getEntityMode() );
}
}
return null;
| void | processValue(int i, java.lang.Object[] values, org.hibernate.type.Type[] types)
Object result = processValue( values[i], types[i] );
if (result!=null) {
substitute = true;
values[i] = result;
}
|
|