@Override public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException { final java.util.List<Integer> deletes = new ArrayList<Integer>(); final Serializable sn = getSnapshot(); final int snSize = Array.getLength( sn ); final int arraySize = Array.getLength( array ); int end; if ( snSize > arraySize ) { for ( int i=arraySize; i<snSize; i++ ) { deletes.add( i ); } end = arraySize; } else { end = snSize; } for ( int i=0; i<end; i++ ) { if ( Array.get( array, i ) == null && Array.get( sn, i ) != null ) { deletes.add( i ); } } return deletes.iterator(); }
private static void addIdToCollectionInfoString( CollectionPersister persister, Serializable id, SessionFactoryImplementor factory, StringBuilder s ) { // Need to use the identifier type of the collection owner // since the incoming is value is actually the owner's id. // Using the collection's key type causes problems with // property-ref keys. // Also need to check that the expected identifier type matches // the given ID. Due to property-ref keys, the collection key // may not be the owner key. Type ownerIdentifierType = persister.getOwnerEntityPersister() .getIdentifierType(); if ( id.getClass().isAssignableFrom( ownerIdentifierType.getReturnedClass() ) ) { s.append( ownerIdentifierType.toLoggableString( id, factory ) ); } else { // TODO: This is a crappy backup if a property-ref is used. // If the reference is an object w/o toString(), this isn't going to work. s.append( id.toString() ); } }
@Override @SuppressWarnings("deprecation") public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final ArrayList snapshot = (ArrayList) getSnapshot(); final List elements = element.elements( persister.getElementNodeName() ); if ( snapshot.size() != elements.size() ) { return false; } for ( int i=0; i<snapshot.size(); i++ ) { final Object old = snapshot.get( i ); final Element elem = (Element) elements.get( i ); final Object current = elementType.fromXMLNode( elem, persister.getFactory() ); if ( elementType.isDirty( old, current, getSession() ) ) { return false; } } return true; }
/** * Constructs a PersistentElementHolder * * @param session The session * @param persister The collection persister * @param key The collection key (the fk value) */ @SuppressWarnings("UnusedDeclaration") public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key) { super( session ); final Element owner = (Element) session.getPersistenceContext().getCollectionOwner( key, persister ); if ( owner == null ) { throw new AssertionFailure("null owner"); } final String nodeName = persister.getNodeName(); if ( ".".equals( nodeName ) ) { element = owner; } else { element = owner.element( nodeName ); if ( element == null ) { element = owner.addElement( nodeName ); } } }
@Override @SuppressWarnings("deprecation") public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final String indexNode = getIndexAttributeName( persister ); final HashMap snapshot = (HashMap) getSnapshot(); final List elements = element.elements( persister.getElementNodeName() ); if ( snapshot.size() != elements.size() ) { return false; } for ( int i=0; i<snapshot.size(); i++ ) { final Element elem = (Element) elements.get( i ); final Object old = snapshot.get( getIndex( elem, indexNode, i ) ); final Object current = elementType.fromXMLNode( elem, persister.getFactory() ); if ( elementType.isDirty( old, current, getSession() ) ) { return false; } } return true; }
@Override public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final List sn = (List) getSnapshot(); if ( sn.size()!=this.list.size() ) { return false; } final Iterator itr = list.iterator(); final Iterator snapshotItr = sn.iterator(); while ( itr.hasNext() ) { if ( elementType.isDirty( itr.next(), snapshotItr.next(), getSession() ) ) { return false; } } return true; }
@Override public Serializable getSnapshot(CollectionPersister persister) throws HibernateException { // final int length = (array==null) ? tempList.size() : Array.getLength( array ); final int length = Array.getLength( array ); final Serializable result = (Serializable) Array.newInstance( persister.getElementClass(), length ); for ( int i=0; i<length; i++ ) { // final Object elt = (array==null) ? tempList.get( i ) : Array.get( array, i ); final Object elt = Array.get( array, i ); try { Array.set( result, i, persister.getElementType().deepCopy( elt, persister.getFactory() ) ); } catch (IllegalArgumentException iae) { LOG.invalidArrayElementType( iae.getMessage() ); throw new HibernateException( "Array element type error", iae ); } } return result; }
@Override public ExpandingCollectionQuerySpace makeCollectionQuerySpace( String uid, CollectionPersister collectionPersister, boolean canJoinsBeRequired) { checkQuerySpaceDoesNotExist( uid ); final ExpandingCollectionQuerySpace space = new CollectionQuerySpaceImpl( collectionPersister, uid, this, canJoinsBeRequired ); registerQuerySpace( space ); return space; }
@Override @SuppressWarnings("unchecked") public Object readFrom( ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) throws HibernateException, SQLException { final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ); if ( element != null ) { final Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ); if ( loadingEntries == null ) { loadingEntries = new ArrayList<Object[]>(); } loadingEntries.add( new Object[] { index, element } ); } return element; }
@Override public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final Map snap = (Map) getSnapshot(); if ( snap.size()!= values.size() ) { return false; } for ( int i=0; i<values.size(); i++ ) { final Object value = values.get( i ); final Object id = identifiers.get( i ); if ( id == null ) { return false; } final Object old = snap.get( id ); if ( elementType.isDirty( old, value, getSession() ) ) { return false; } } return true; }
@Override public long getNumberOfAssociations(SessionFactory sessionFactory) { int associationCount = 0; IgniteDatastoreProvider datastoreProvider = getProvider( sessionFactory ); for ( CollectionPersister collectionPersister : ( (SessionFactoryImplementor) sessionFactory ).getCollectionPersisters().values() ) { AssociationKeyMetadata associationKeyMetadata = ( (OgmCollectionPersister) collectionPersister ).getAssociationKeyMetadata(); if ( associationKeyMetadata.getAssociationKind() == AssociationKind.ASSOCIATION ) { IgniteCache<Object, BinaryObject> associationCache = getAssociationCache( sessionFactory, associationKeyMetadata ); StringBuilder query = new StringBuilder( "SELECT " ) .append( StringHelper.realColumnName( associationKeyMetadata.getColumnNames()[0] ) ) .append( " FROM " ).append( associationKeyMetadata.getTable() ); SqlFieldsQuery sqlQuery = datastoreProvider.createSqlFieldsQueryWithLog( query.toString(), null ); Iterable<List<?>> queryResult = associationCache.query( sqlQuery ); Set<Object> uniqs = new HashSet<>(); for ( List<?> row : queryResult ) { Object value = row.get( 0 ); if ( value != null ) { uniqs.add( value ); } } associationCount += uniqs.size(); } } return associationCount; }
@Override @SuppressWarnings("unchecked") public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException { final List deletes = new ArrayList(); final List sn = (List) getSnapshot(); int end; if ( sn.size() > list.size() ) { for ( int i=list.size(); i<sn.size(); i++ ) { deletes.add( indexIsFormula ? sn.get( i ) : i ); } end = list.size(); } else { end = sn.size(); } for ( int i=0; i<end; i++ ) { final Object item = list.get( i ); final Object snapshotItem = sn.get( i ); if ( item == null && snapshotItem != null ) { deletes.add( indexIsFormula ? snapshotItem : i ); } } return deletes.iterator(); }
@Override @SuppressWarnings("deprecation") public Serializable disassemble(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final String indexNodeName = getIndexAttributeName( persister ); final List elements = element.elements( persister.getElementNodeName() ); final int length = elements.size(); final Serializable[] result = new Serializable[length]; for ( int i=0; i<length; i++ ) { final Element elem = (Element) elements.get( i ); final Object object = elementType.fromXMLNode( elem, persister.getFactory() ); final Integer index = IntegerType.INSTANCE.fromString( getIndex( elem, indexNodeName, i ) ); result[index] = elementType.disassemble( object, getSession(), null ); } return result; }
public Object replaceElements( final Object original, final Object target, final Object owner, final java.util.Map copyCache, final SessionImplementor session) throws HibernateException { CollectionPersister cp = session.getFactory().getCollectionPersister( getRole() ); java.util.Map result = (java.util.Map) target; result.clear(); Iterator iter = ( (java.util.Map) original ).entrySet().iterator(); while ( iter.hasNext() ) { java.util.Map.Entry me = (java.util.Map.Entry) iter.next(); Object key = cp.getIndexType().replace( me.getKey(), null, session, owner, copyCache ); Object value = cp.getElementType().replace( me.getValue(), null, session, owner, copyCache ); result.put(key, value); } return result; }
@Override public boolean needsRecreate(CollectionPersister persister) { // Workaround for situations like HHH-7072. If the collection element is a component that consists entirely // of nullable properties, we currently have to forcefully recreate the entire collection. See the use // of hasNotNullableColumns in the AbstractCollectionPersister constructor for more info. In order to delete // row-by-row, that would require SQL like "WHERE ( COL = ? OR ( COL is null AND ? is null ) )", rather than // the current "WHERE COL = ?" (fails for null for most DBs). Note that // the param would have to be bound twice. Until we eventually add "parameter bind points" concepts to the // AST in ORM 5+, handling this type of condition is either extremely difficult or impossible. Forcing // recreation isn't ideal, but not really any other option in ORM 4. if (persister.getElementType() instanceof ComponentType) { ComponentType componentType = (ComponentType) persister.getElementType(); return !componentType.hasNotNullProperty(); } return false; }
@Override @SuppressWarnings("unchecked") public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) throws HibernateException, SQLException { final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ; final int index = (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ); //pad with nulls from the current last element up to the new index for ( int i = list.size(); i<=index; i++) { list.add( i, null ); } list.set( index, element ); return element; }
@Override public void preInsert(CollectionPersister persister) throws HibernateException { final Iterator itr = values.iterator(); int i = 0; while ( itr.hasNext() ) { final Object entry = itr.next(); final Integer loc = i++; if ( !identifiers.containsKey( loc ) ) { //TODO: native ids final Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry ); identifiers.put( loc, id ); } } }
@Override @SuppressWarnings("unchecked") public Serializable getSnapshot(CollectionPersister persister) throws HibernateException { final HashMap map = new HashMap( values.size() ); final Iterator iter = values.iterator(); int i=0; while ( iter.hasNext() ) { final Object value = iter.next(); map.put( identifiers.get( i++ ), persister.getElementType().deepCopy( value, persister.getFactory() ) ); } return map; }
@Override @SuppressWarnings("unchecked") public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException { final Map snap = (Map) getSnapshot(); final List deletes = new ArrayList( snap.keySet() ); for ( int i=0; i<values.size(); i++ ) { if ( values.get( i ) != null ) { deletes.remove( identifiers.get( i ) ); } } return deletes.iterator(); }
private void doBasicPluralAttributeBinding(PluralAttributeSource source, AbstractPluralAttributeBinding binding) { binding.setFetchTiming( source.getFetchTiming() ); binding.setFetchStyle( source.getFetchStyle() ); binding.setCascadeStyles( source.getCascadeStyles() ); binding.setCaching( source.getCaching() ); binding.getHibernateTypeDescriptor().setJavaTypeName( source.getPluralAttributeNature().reportedJavaType().getName() ); binding.getHibernateTypeDescriptor().setExplicitTypeName( source.getTypeInformation().getName() ); binding.getHibernateTypeDescriptor().getTypeParameters().putAll( source.getTypeInformation().getParameters() ); if ( StringHelper.isNotEmpty( source.getCustomPersisterClassName() ) ) { binding.setCollectionPersisterClass( currentBindingContext.<CollectionPersister>locateClassByName( source.getCustomPersisterClassName() ) ); } if ( source.getCustomPersisterClassName() != null ) { binding.setCollectionPersisterClass( metadata.<CollectionPersister>locateClassByName( source.getCustomPersisterClassName() ) ); } binding.setCustomLoaderName( source.getCustomLoaderName() ); binding.setCustomSqlInsert( source.getCustomSqlInsert() ); binding.setCustomSqlUpdate( source.getCustomSqlUpdate() ); binding.setCustomSqlDelete( source.getCustomSqlDelete() ); binding.setCustomSqlDeleteAll( source.getCustomSqlDeleteAll() ); binding.setMetaAttributeContext( buildMetaAttributeContext( source.metaAttributes(), binding.getContainer().getMetaAttributeContext() ) ); doBasicAttributeBinding( source, binding ); }
protected Boolean readIndexExistence(final Object index) { if ( !initialized ) { final Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded( new LazyInitializationWork<Boolean>() { @Override public Boolean doWork() { final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this ); final CollectionPersister persister = entry.getLoadedPersister(); if ( persister.isExtraLazy() ) { if ( hasQueuedOperations() ) { session.flush(); } return persister.indexExists( entry.getLoadedKey(), index, session ); } else { read(); } return null; } } ); if ( extraLazyExistenceCheck != null ) { return extraLazyExistenceCheck; } } return null; }
@Override public void evictCollection(String role, Serializable ownerIdentifier) { CollectionPersister p = sessionFactory.getCollectionPersister( role ); if ( p.hasCache() ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( "Evicting second-level cache: %s", MessageHelper.collectionInfoString( p, ownerIdentifier, sessionFactory ) ); } CacheKey cacheKey = buildCacheKey( ownerIdentifier, p ); p.getCacheAccessStrategy().evict( cacheKey ); } }
@Override public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) throws HibernateException { final Serializable[] cached = (Serializable[]) disassembled; array = Array.newInstance( persister.getElementClass(), cached.length ); for ( int i=0; i<cached.length; i++ ) { Array.set( array, i, persister.getElementType().assemble( cached[i], getSession(), owner ) ); } }
private void endCollectionLoad( final Object resultSetId, final SessionImplementor session, final CollectionPersister collectionPersister) { //this is a query and we are loading multiple instances of the same collection role session.getPersistenceContext() .getLoadContexts() .getCollectionLoadContext( ( ResultSet ) resultSetId ) .endLoadingCollections( collectionPersister ); }
private void handlePotentiallyEmptyCollectionRootReturns( LoadPlan loadPlan, Serializable[] collectionKeys, ResultSet resultSet, SessionImplementor session) { if ( collectionKeys == null ) { // this is not a collection initializer (and empty collections will be detected by looking for // the owner's identifier in the result set) return; } // this is a collection initializer, so we must create a collection // for each of the passed-in keys, to account for the possibility // that the collection is empty and has no rows in the result set // // todo : move this inside CollectionReturn ? CollectionPersister persister = ( (CollectionReturn) loadPlan.getReturns().get( 0 ) ).getCollectionPersister(); for ( Serializable key : collectionKeys ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( "Preparing collection intializer : %s", MessageHelper.collectionInfoString( persister, key, session.getFactory() ) ); } session.getPersistenceContext() .getLoadContexts() .getCollectionLoadContext( resultSet ) .getLoadingCollection( persister, key ); } }
@Override public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final Serializable snapshot = getSnapshot(); final int xlen = Array.getLength( snapshot ); if ( xlen!= Array.getLength( array ) ) { return false; } for ( int i=0; i<xlen; i++) { if ( elementType.isDirty( Array.get( snapshot, i ), Array.get( array, i ), getSession() ) ) { return false; } } return true; }
@Override @SuppressWarnings("unchecked") public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) throws HibernateException, SQLException { // note that if we load this collection from a cartesian product // the multiplicity would be broken ... so use an idbag instead final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ; if ( element != null ) { bag.add( element ); } return element; }
/** * Generate the collection reference aliases for a particular {@link org.hibernate.loader.plan.spi.CollectionReference} * and register the generated value using the query space UID. * <p/> * Once generated, there are two methods that can be used to do look ups by the specified * query space UID: * <ul> * <li> * {@link ##resolveCollectionReferenceAliases(String)} can be used to * look up the returned collection reference aliases; * </li> * <li> * {@link #resolveSqlTableAliasFromQuerySpaceUid(String)} can be used to * look up the SQL collection table alias. * </li> * </ul> * * @param collectionQuerySpaceUid The query space UID for the collection reference. * @param persister The collection persister for collection reference. * @param elementQuerySpaceUid The query space UID for the collection element if * the element is an entity type; null, otherwise. * @return the generated collection reference aliases. * @throws IllegalArgumentException if the collection element is an entity type and * {@code elementQuerySpaceUid} is null. * * @see org.hibernate.loader.plan.spi.CollectionReference#getQuerySpaceUid() * @see org.hibernate.loader.plan.spi.CollectionReference#getCollectionPersister() */ public CollectionReferenceAliases generateCollectionReferenceAliases( String collectionQuerySpaceUid, CollectionPersister persister, String elementQuerySpaceUid) { if ( persister.getElementType().isEntityType() && elementQuerySpaceUid == null ) { throw new IllegalArgumentException( "elementQuerySpaceUid must be non-null for one-to-many or many-to-many associations." ); } final String manyToManyTableAlias; final String tableAlias; if ( persister.isManyToMany() ) { manyToManyTableAlias = createTableAlias( persister.getRole() ); tableAlias = createTableAlias( persister.getElementDefinition().toEntityDefinition().getEntityPersister() ); } else { manyToManyTableAlias = null; tableAlias = createTableAlias( persister.getRole() ); } final CollectionReferenceAliases collectionAliases = new CollectionReferenceAliasesImpl( tableAlias, manyToManyTableAlias, createCollectionAliases( persister ), createCollectionElementAliases( persister, tableAlias, elementQuerySpaceUid ) ); registerQuerySpaceAliases( collectionQuerySpaceUid, collectionAliases ); return collectionAliases; }
@Override public Object processCollection(Object collection, CollectionType type) throws HibernateException { if ( collection == null ) { return null; } final SessionImplementor session = getSession(); final CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() ); if ( collection instanceof PersistentCollection ) { final PersistentCollection persistentCollection = (PersistentCollection) collection; if ( persistentCollection.setCurrentSession( session ) ) { if ( isOwnerUnchanged( persistentCollection, persister, extractCollectionKeyFromOwner( persister ) ) ) { // a "detached" collection that originally belonged to the same entity if ( persistentCollection.isDirty() ) { throw new HibernateException( "reassociated object has dirty collection" ); } reattachCollection( persistentCollection, type ); } else { // a "detached" collection that belonged to a different entity throw new HibernateException( "reassociated object has dirty collection reference" ); } } else { // a collection loaded in the current session // can not possibly be the collection belonging // to the entity passed to update() throw new HibernateException( "reassociated object has dirty collection reference" ); } } else { // brand new collection //TODO: or an array!! we can't lock objects with arrays now?? throw new HibernateException( "reassociated object has dirty collection reference (or an array)" ); } return null; }
public CollectionQuerySpaceImpl( CollectionPersister persister, String uid, ExpandingQuerySpaces querySpaces, boolean canJoinsBeRequired) { super( uid, Disposition.COLLECTION, querySpaces, canJoinsBeRequired ); this.persister = persister; }
protected Boolean readElementExistence(final Object element) { if ( !initialized ) { final Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded( new LazyInitializationWork<Boolean>() { @Override public Boolean doWork() { final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this ); final CollectionPersister persister = entry.getLoadedPersister(); if ( persister.isExtraLazy() ) { if ( hasQueuedOperations() ) { session.flush(); } return persister.elementExists( entry.getLoadedKey(), element, session ); } else { read(); } return null; } } ); if ( extraLazyExistenceCheck != null ) { return extraLazyExistenceCheck; } } return null; }
protected static String getAffectedOwnerEntityName(CollectionPersister collectionPersister, Object affectedOwner, EventSource source ) { // collectionPersister should not be null, but we don't want to throw // an exception if it is null String entityName = ( collectionPersister == null ? null : collectionPersister.getOwnerEntityPersister().getEntityName() ); if ( affectedOwner != null ) { EntityEntry ee = source.getPersistenceContext().getEntry( affectedOwner ); if ( ee != null && ee.getEntityName() != null) { entityName = ee.getEntityName(); } } return entityName; }
/** * Assembles the collection from the cached state. * * @param collection The persistent collection instance being assembled * @param persister The collection persister * @param owner The collection owner instance */ public void assemble( final PersistentCollection collection, final CollectionPersister persister, final Object owner) { collection.initializeFromCache( persister, state, owner ); collection.afterInitialize(); }
@Override @SuppressWarnings("deprecation") public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) throws HibernateException { final Type elementType = persister.getElementType(); final String indexNodeName = getIndexAttributeName( persister ); final Serializable[] cached = (Serializable[]) disassembled; for ( int i=0; i<cached.length; i++ ) { final Object object = elementType.assemble( cached[i], getSession(), owner ); final Element subelement = element.addElement( persister.getElementNodeName() ); elementType.setToXMLNode( subelement, object, persister.getFactory() ); setIndex( subelement, indexNodeName, Integer.toString( i ) ); } }
/** * Constructs an AbstractCollectionEvent object. * * @param collection - the collection * @param source - the Session source * @param affectedOwner - the owner that is affected by this event; * can be null if unavailable * @param affectedOwnerId - the ID for the owner that is affected * by this event; can be null if unavailable * that is affected by this event; can be null if unavailable */ public AbstractCollectionEvent( CollectionPersister collectionPersister, PersistentCollection collection, EventSource source, Object affectedOwner, Serializable affectedOwnerId) { super(source); this.collection = collection; this.affectedOwner = affectedOwner; this.affectedOwnerId = affectedOwnerId; this.affectedOwnerEntityName = getAffectedOwnerEntityName( collectionPersister, affectedOwner, source ); }
@Override @SuppressWarnings( {"unchecked"}) public CollectionPersister createCollectionPersister( Configuration cfg, Collection collectionMetadata, CollectionRegionAccessStrategy cacheAccessStrategy, SessionFactoryImplementor factory) throws HibernateException { Class<? extends CollectionPersister> persisterClass = collectionMetadata.getCollectionPersisterClass(); if ( persisterClass == null ) { persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getCollectionPersisterClass( collectionMetadata ); } return create( persisterClass, COLLECTION_PERSISTER_CONSTRUCTOR_ARGS, cfg, collectionMetadata, cacheAccessStrategy, factory ); }
private static boolean isSubsequentSelectDelayed(AssociationType type, SessionFactoryImplementor sessionFactory) { if ( type.isAnyType() ) { // we'd need more context here. this is only kept as part of the property state on the owning entity return false; } else if ( type.isEntityType() ) { return ( (EntityPersister) type.getAssociatedJoinable( sessionFactory ) ).hasProxy(); } else { final CollectionPersister cp = ( (CollectionPersister) type.getAssociatedJoinable( sessionFactory ) ); return cp.isLazy() || cp.isExtraLazy(); } }
@Override public CollectionDefinition toCollectionDefinition() { if ( isEntityType() ) { throw new IllegalStateException( "Cannot treat entity attribute as collection type" ); } if ( isAnyType() ) { throw new IllegalStateException( "Cannot treat any-type attribute as collection type" ); } return (CollectionPersister) getJoinable(); }
public CollectionPersister getCollectionPersister(String role) throws MappingException { CollectionPersister result = collectionPersisters.get(role); if ( result == null ) { throw new MappingException( "Unknown collection role: " + role ); } return result; }
@Override @SuppressWarnings("deprecation") public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) throws HibernateException, SQLException { final Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ); final Type elementType = persister.getElementType(); final Element subElement = element.addElement( persister.getElementNodeName() ); elementType.setToXMLNode( subElement, object, persister.getFactory() ); return object; }