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

The following examples show how to use org.hibernate.type.Type#isDirty() . 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: PersistentMap.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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 2
Source File: PersistentSet.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	Type elementType = persister.getElementType();
	java.util.Map sn = (java.util.Map) getSnapshot();
	if ( sn.size()!=set.size() ) {
		return false;
	}
	else {
		Iterator iter = set.iterator();
		while ( iter.hasNext() ) {
			Object test = iter.next();
			Object oldValue = sn.get(test);
			if ( oldValue==null || elementType.isDirty( oldValue, test, getSession() ) ) return false;
		}
		return true;
	}
}
 
Example 3
Source File: PersistentIdentifierBag.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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 4
Source File: PersistentIdentifierBag.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	Type elementType = persister.getElementType();
	Map snap = (Map) getSnapshot();
	if ( snap.size()!= values.size() ) return false;
	for ( int i=0; i<values.size(); i++ ) {
		Object value = values.get(i);
		Object id = identifiers.get( new Integer(i) );
		if (id==null) return false;
		Object old = snap.get(id);
		if ( elementType.isDirty( old, value, getSession() ) ) return false;
	}
	return true;
}
 
Example 5
Source File: PersistentIndexedElementHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 6
Source File: PersistentIndexedElementHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean needsUpdating(Object entry, int i, Type elementType) 
throws HibernateException {
	HashMap snapshot = (HashMap) getSnapshot();
	IndexedValue iv = (IndexedValue) entry;
	Object old = snapshot.get( iv.index );
	return old!=null && elementType.isDirty( old, iv.value, getSession() );
}
 
Example 7
Source File: PersistentElementHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 8
Source File: PersistentMap.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean needsUpdating(Object entry, int i, Type elemType) 
throws HibernateException {
	final Map sn = (Map) getSnapshot();
	Map.Entry e = (Map.Entry) entry;
	Object snValue = sn.get( e.getKey() );
	return e.getValue()!=null &&
		snValue!=null &&
		elemType.isDirty( snValue, e.getValue(), getSession() );
}
 
Example 9
Source File: PersistentMap.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	Type elementType = persister.getElementType();
	Map xmap = (Map) getSnapshot();
	if ( xmap.size()!=this.map.size() ) return false;
	Iterator iter = map.entrySet().iterator();
	while ( iter.hasNext() ) {
		Map.Entry entry = (Map.Entry) iter.next();
		if ( elementType.isDirty( entry.getValue(), xmap.get( entry.getKey() ), getSession() ) ) return false;
	}
	return true;
}
 
Example 10
Source File: PersistentIdentifierBag.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {

		if (entry==null) return false;
		Map snap = (Map) getSnapshot();
		Object id = identifiers.get( new Integer(i) );
		if (id==null) return false;
		Object old = snap.get(id);
		return old!=null && elemType.isDirty( old, entry, getSession() );
	}
 
Example 11
Source File: PersistentSet.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 && entry != null ) || elemType.isDirty( oldValue, entry, getSession() );
}
 
Example 12
Source File: PersistentArrayHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
	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 13
Source File: PersistentArrayHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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
Source File: PersistentArrayHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 15
Source File: PersistentMap.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 16
Source File: PersistentList.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 17
Source File: PersistentSet.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
	final java.util.Map sn = (java.util.Map) getSnapshot();
	Object oldValue = sn.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 18
Source File: PersistentIdentifierBag.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 19
Source File: PersistentList.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 20
Source File: PersistentElementHolder.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean needsInserting(Object entry, int i, Type elementType) 
throws HibernateException {
	ArrayList snapshot = (ArrayList) getSnapshot();
	return i>=snapshot.size() || elementType.isDirty( snapshot.get(i), entry, getSession() );
}