Java Code Examples for org.hibernate.type.Type.isDirty()

The following are Jave code examples for showing how to use isDirty() of the org.hibernate.type.Type class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: PersistentIdentifierBag.java   View Source Code Vote up 6 votes
@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;
}
 
Example 2
Project: lams   File: PersistentList.java   View Source Code Vote up 6 votes
@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;
}
 
Example 3
Project: lams   File: PersistentMap.java   View Source Code Vote up 6 votes
@Override
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	final Type elementType = persister.getElementType();
	final Map snapshotMap = (Map) getSnapshot();
	if ( snapshotMap.size() != this.map.size() ) {
		return false;
	}

	for ( Object o : map.entrySet() ) {
		final Entry entry = (Entry) o;
		if ( elementType.isDirty( entry.getValue(), snapshotMap.get( entry.getKey() ), getSession() ) ) {
			return false;
		}
	}
	return true;
}
 
Example 4
Project: lams   File: PersistentElementHolder.java   View Source Code Vote up 6 votes
@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;
}
 
Example 5
Project: lams   File: PersistentElementHolder.java   View Source Code Vote up 6 votes
@Override
@SuppressWarnings({"unchecked", "deprecation"})
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
	final Type elementType = persister.getElementType();
	final ArrayList snapshot = (ArrayList) getSnapshot();
	final List elements = element.elements( persister.getElementNodeName() );
	final ArrayList result = new ArrayList();
	for ( int i=0; i<snapshot.size(); i++ ) {
		final Object old = snapshot.get( i );
		if ( i >= elements.size() ) {
			result.add( old );
		}
		else {
			final Element elem = (Element) elements.get( i );
			final Object object = elementType.fromXMLNode( elem, persister.getFactory() );
			if ( elementType.isDirty( old, object, getSession() ) ) {
				result.add( old );
			}
		}
	}
	return result.iterator();
}
 
Example 6
Project: lams   File: PersistentIndexedElementHolder.java   View Source Code Vote up 6 votes
@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;
}
 
Example 7
Project: lams   File: PersistentSet.java   View Source Code Vote up 6 votes
@Override
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	final Type elementType = persister.getElementType();
	final java.util.Map sn = (java.util.Map) getSnapshot();
	if ( sn.size()!=set.size() ) {
		return false;
	}
	else {
		for ( Object test : set ) {
			final Object oldValue = sn.get( test );
			if ( oldValue == null || elementType.isDirty( oldValue, test, getSession() ) ) {
				return false;
			}
		}
		return true;
	}
}
 
Example 8
Project: lams   File: PersistentIdentifierBag.java   View Source Code Vote up 5 votes
@Override
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
	if ( entry == null ) {
		return false;
	}

	final Map snap = (Map) getSnapshot();
	final Object id = identifiers.get( i );
	if ( id == null ) {
		return false;
	}

	final Object old = snap.get( id );
	return old != null && elemType.isDirty( old, entry, getSession() );
}
 
Example 9
Project: lams   File: PersistentList.java   View Source Code Vote up 5 votes
@Override
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
	final List sn = (List) getSnapshot();
	return i < sn.size()
			&& sn.get( i ) != null
			&& list.get( i ) != null
			&& elemType.isDirty( list.get( i ), sn.get( i ), getSession() );
}
 
Example 10
Project: lams   File: PersistentMap.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
	final Map sn = (Map) getSnapshot();
	final Map.Entry e = (Map.Entry) entry;
	final Object snValue = sn.get( e.getKey() );
	return e.getValue() != null
			&& snValue != null
			&& elemType.isDirty( snValue, e.getValue(), getSession() );
}
 
Example 11
Project: lams   File: PersistentIndexedElementHolder.java   View Source Code Vote up 5 votes
@Override
public boolean needsUpdating(Object entry, int i, Type elementType) throws HibernateException {
	final HashMap snapshot = (HashMap) getSnapshot();
	final IndexedValue iv = (IndexedValue) entry;
	final Object old = snapshot.get( iv.index );
	return old!=null && elementType.isDirty( old, iv.value, getSession() );
}
 
Example 12
Project: lams   File: PersistentArrayHolder.java   View Source Code Vote up 5 votes
@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;
}
 
Example 13
Project: lams   File: PersistentArrayHolder.java   View Source Code Vote up 5 votes
@Override
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
	final Serializable sn = getSnapshot();
	return i < Array.getLength( sn )
			&& Array.get( sn, i ) != null
			&& Array.get( array, i ) != null
			&& elemType.isDirty( Array.get( array, i ), Array.get( sn, i ), getSession() );
}
 
Example 14
Project: lams   File: PersistentSet.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
	final Object oldValue = ( (java.util.Map) getSnapshot() ).get( entry );
	// note that it might be better to iterate the snapshot but this is safe,
	// assuming the user implements equals() properly, as required by the Set
	// contract!
	return oldValue == null || elemType.isDirty( oldValue, entry, getSession() );
}
 
Example 15
Project: lams   File: PersistentElementHolder.java   View Source Code Vote up 4 votes
@Override
public boolean needsInserting(Object entry, int i, Type elementType) throws HibernateException {
	final ArrayList snapshot = (ArrayList) getSnapshot();
	return i >= snapshot.size()
			|| elementType.isDirty( snapshot.get( i ), entry, getSession() );
}