Java Code Examples for org.hibernate.persister.collection.CollectionPersister#readElement()

The following examples show how to use org.hibernate.persister.collection.CollectionPersister#readElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentIdentifierBag.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
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 Object old = identifiers.put(
		values.size(),
		persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() )
	);

	if ( old == null ) {
		//maintain correct duplication if loaded in a cartesian product
		values.add( element );
	}
	return element;
}
 
Example 2
Source File: PersistentMap.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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<>();
		}
		loadingEntries.add( new Object[] { index, element } );
	}
	return element;
}
 
Example 3
Source File: PersistentIndexedElementHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
	Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	final Type elementType = persister.getElementType();
	final SessionFactoryImplementor factory = persister.getFactory();
	String indexNode = getIndexAttributeName(persister);

	Element elem = element.addElement( persister.getElementNodeName() );
	elementType.setToXMLNode( elem, object, factory ); 
	
	final Type indexType = persister.getIndexType();
	final Object indexValue = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
	final String index = ( (NullableType) indexType ).toXMLString( indexValue, factory );
	setIndex(elem, indexNode, index);
	return object;
}
 
Example 4
Source File: PersistentList.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 5
Source File: PersistentBag.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 6
Source File: PersistentArrayHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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() );
	for ( int i = tempList.size(); i<=index; i++) {
		tempList.add( i, null );
	}
	tempList.set( index, element );
	return element;
}
 
Example 7
Source File: PersistentSet.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 ) {
		tempList.add( element );
	}
	return element;
}
 
Example 8
Source File: PersistentIdentifierBag.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object readFrom(
	ResultSet rs,
	CollectionPersister persister,
	CollectionAliases descriptor,
	Object owner)
	throws HibernateException, SQLException {

	Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	Object old = identifiers.put(
		new Integer( values.size() ),
		persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() )
	);
	if ( old==null ) values.add(element); //maintain correct duplication if loaded in a cartesian product
	return element;
}
 
Example 9
Source File: PersistentList.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) 
throws HibernateException, SQLException {
	Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
	int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
	
	//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;
}
 
Example 10
Source File: PersistentBag.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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
	Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
	if (element!=null) bag.add(element);
	return element;
}
 
Example 11
Source File: PersistentMap.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
	Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
	if ( element!=null ) map.put(index, element);
	return element;
}
 
Example 12
Source File: PersistentElementHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
	Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	final Type elementType = persister.getElementType();
	Element subelement = element.addElement( persister.getElementNodeName() );
	elementType.setToXMLNode( subelement, object, persister.getFactory() ); 
	return object;
}
 
Example 13
Source File: PersistentArrayHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {

	Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
	for ( int i = tempList.size(); i<=index; i++) {
		tempList.add(i, null);
	}
	tempList.set(index, element);
	return element;
}
 
Example 14
Source File: PersistentSet.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object readFrom(
        ResultSet rs,
        CollectionPersister persister,
        CollectionAliases descriptor,
        Object owner) throws HibernateException, SQLException {
	Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	if (element!=null) tempList.add(element);
	return element;
}