Java Code Examples for org.hibernate.type.Type#fromXMLNode()

The following examples show how to use org.hibernate.type.Type#fromXMLNode() . These examples are extracted from open source projects. 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
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
	
	Type elementType = persister.getElementType();
	Type indexType = persister.getIndexType();
	final String indexNodeName = getIndexAttributeName(persister);

	List elements =  element.elements( persister.getElementNodeName() );
	int length = elements.size();
	Serializable[] result = new Serializable[length*2];
	for ( int i=0; i<length*2; ) {
		Element elem = (Element) elements.get(i/2);
		Object object = elementType.fromXMLNode( elem, persister.getFactory() );
		final String indexString = getIndex(elem, indexNodeName, i);
		Object index = ( (NullableType) indexType ).fromXMLString( indexString, persister.getFactory() );
		result[i++] = indexType.disassemble( index, getSession(), null );
		result[i++] = elementType.disassemble( object, getSession(), null );
	}
	return result;
}
 
Example 2
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) 
throws HibernateException {
	
	Type elementType = persister.getElementType();
	ArrayList snapshot = (ArrayList) getSnapshot();
	List elements = element.elements( persister.getElementNodeName() );
	ArrayList result = new ArrayList();
	for ( int i=0; i<snapshot.size(); i++ ) {
		Object old = snapshot.get(i);
		if ( i >= elements.size() ) {
			result.add(old);
		}
		else {
			Element elem = (Element) elements.get(i);
			Object object = elementType.fromXMLNode( elem, persister.getFactory() );
			if ( elementType.isDirty( old, object, getSession() ) ) result.add(old);
		}
	}
	return result.iterator();
	
}
 
Example 3
public Serializable getSnapshot(CollectionPersister persister) 
throws HibernateException {
	
	final Type elementType = persister.getElementType();
	String indexNode = getIndexAttributeName(persister);		
	List elements = element.elements( persister.getElementNodeName() );
	HashMap snapshot = new HashMap( elements.size() );
	for ( int i=0; i<elements.size(); i++ ) {
		Element elem = (Element) elements.get(i);
		Object value = elementType.fromXMLNode( elem, persister.getFactory() );
		Object copy = elementType.deepCopy( value, getSession().getEntityMode(), persister.getFactory() );
		snapshot.put( getIndex(elem, indexNode, i), copy );
	}
	return snapshot;
	
}
 
Example 4
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
			
	Type elementType = persister.getElementType();
	final String indexNodeName = getIndexAttributeName(persister);
	List elements =  element.elements( persister.getElementNodeName() );
	int length = elements.size();
	Serializable[] result = new Serializable[length];
	for ( int i=0; i<length; i++ ) {
		Element elem = (Element) elements.get(i);
		Object object = elementType.fromXMLNode( elem, persister.getFactory() );
		Integer index = (Integer) Hibernate.INTEGER.fromStringValue( getIndex(elem, indexNodeName, i) );
		result[ index.intValue() ] = elementType.disassemble( object, getSession(), null );
	}
	return result;
}
 
Example 5
public Serializable getSnapshot(CollectionPersister persister) 
throws HibernateException {
	
	final Type elementType = persister.getElementType();		
	List elements = element.elements( persister.getElementNodeName() );
	ArrayList snapshot = new ArrayList( elements.size() );
	for ( int i=0; i<elements.size(); i++ ) {
		Element elem = (Element) elements.get(i);
		Object value = elementType.fromXMLNode( elem, persister.getFactory() );
		Object copy = elementType.deepCopy(value , getSession().getEntityMode(), persister.getFactory() );
		snapshot.add(copy);
	}
	return snapshot;
	
}
 
Example 6
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	Type elementType = persister.getElementType();
	
	ArrayList snapshot = (ArrayList) getSnapshot();
	List elements = element.elements( persister.getElementNodeName() );
	if ( snapshot.size()!= elements.size() ) return false;
	for ( int i=0; i<snapshot.size(); i++ ) {
		Object old = snapshot.get(i);
		Element elem = (Element) elements.get(i);
		Object current = elementType.fromXMLNode( elem, persister.getFactory() );
		if ( elementType.isDirty( old, current, getSession() ) ) return false;
	}
	return true;
}
 
Example 7
public Iterator entries(CollectionPersister persister) {
	
	final Type elementType = persister.getElementType();
	List elements =  element.elements( persister.getElementNodeName() );
	int length = elements.size();
	List result = new ArrayList(length);
	for ( int i=0; i<length; i++ ) {
		Element elem = (Element) elements.get(i);
		Object object = elementType.fromXMLNode( elem, persister.getFactory() );
		result.add(object);
	}
	return result.iterator();
}
 
Example 8
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
	
	Type elementType = persister.getElementType();
	List elements =  element.elements( persister.getElementNodeName() );
	int length = elements.size();
	Serializable[] result = new Serializable[length];
	for ( int i=0; i<length; i++ ) {
		Element elem = (Element) elements.get(i);
		Object object = elementType.fromXMLNode( elem, persister.getFactory() );
		result[i] = elementType.disassemble( object, getSession(), null );
	}
	return result;
}
 
Example 9
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	Type elementType = persister.getElementType();
	String indexNode = getIndexAttributeName(persister);		
	HashMap snapshot = (HashMap) getSnapshot();
	List elements = element.elements( persister.getElementNodeName() );
	if ( snapshot.size()!= elements.size() ) return false;
	for ( int i=0; i<snapshot.size(); i++ ) {
		Element elem = (Element) elements.get(i);
		Object old = snapshot.get( getIndex(elem, indexNode, i) );
		Object current = elementType.fromXMLNode( elem, persister.getFactory() );
		if ( elementType.isDirty( old, current, getSession() ) ) return false;
	}
	return true;
}
 
Example 10
public Iterator entries(CollectionPersister persister) {
	
	final Type elementType = persister.getElementType();
	String indexNode = getIndexAttributeName(persister);
	List elements =  element.elements( persister.getElementNodeName() );
	int length = elements.size();
	List result = new ArrayList(length);
	for ( int i=0; i<length; i++ ) {
		Element elem = (Element) elements.get(i);
		Object object = elementType.fromXMLNode( elem, persister.getFactory() );
		result.add( new IndexedValue( getIndex(elem, indexNode, i), object ) );
	}
	return result.iterator();
}