private int countOccurrences(Object element, List list, Type elementType) throws HibernateException { final Iterator iter = list.iterator(); int result = 0; while ( iter.hasNext() ) { if ( elementType.isSame( element, iter.next() ) ) { result++; } } return result; }
/** * Checks whether the old collection element and new collection element are the same. * By default, this delegates to the collection persister's {@link CollectionPersister#getElementType()}. * * @param collectionPersister The collection persister. * @param oldObject The collection element from the old persistent collection. * @param newObject The collection element from the new persistent collection. * * @return true if the two objects are the same, false otherwise. */ protected boolean isSame(CollectionPersister collectionPersister, Object oldObject, Object newObject) { return collectionPersister.getElementType().isSame( oldObject, newObject ); }
@Override protected boolean isSame(CollectionPersister collectionPersister, Object oldObject, Object newObject) { final Map.Entry oldEntry = Map.Entry.class.cast( oldObject ); final Map.Entry newEntry = Map.Entry.class.cast( newObject ); if ( collectionPersister.getKeyType().isSame( oldEntry.getKey(), newEntry.getKey() ) ) { if ( collectionPersister.getElementType().isSame( oldEntry.getValue(), newEntry.getValue() ) ) { return true; } } return false; }
@Override public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { final List sn = (List) getSnapshot(); if ( sn.size() > i && elemType.isSame( sn.get( i ), entry ) ) { //a shortcut if its location didn't change! return false; } else { //search for it //note that this code is incorrect for other than one-to-many for ( Object old : sn ) { if ( elemType.isSame( old, entry ) ) { return false; } } return true; } }
@Override public boolean isSame(Object x, Object y) throws HibernateException { if ( x == y ) { return true; } // null value and empty component are considered equivalent Object[] xvalues = getPropertyValues( x, entityMode ); Object[] yvalues = getPropertyValues( y, entityMode ); for ( int i = 0; i < propertySpan; i++ ) { if ( !propertyTypes[i].isSame( xvalues[i], yvalues[i] ) ) { return false; } } return true; }
@Override public boolean isSame(Object x, Object y) throws HibernateException { return delegate.isSame( x, y ); }
private int countOccurrences(Object element, java.util.List list, Type elementType, EntityMode entityMode) throws HibernateException { Iterator iter = list.iterator(); int result=0; while ( iter.hasNext() ) { if ( elementType.isSame( element, iter.next(), entityMode ) ) result++; } return result; }
private int countOccurrences(Object element, List list, Type elementType) throws HibernateException { Iterator iter = list.iterator(); int result=0; while ( iter.hasNext() ) { if ( elementType.isSame( element, iter.next() ) ) result++; } return result; }
private int countOccurrences(Object element, List list, Type elementType, EntityMode entityMode) throws HibernateException { Iterator iter = list.iterator(); int result=0; while ( iter.hasNext() ) { if ( elementType.isSame( element, iter.next(), entityMode ) ) result++; } return result; }
private int countOccurrences(Object element, List list, Type elementType) throws HibernateException { Iterator iter = list.iterator(); int result=0; while ( iter.hasNext() ) { if ( elementType.isSame( element, iter.next() ) ) result++; } return result; }
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags"); List sn = (List) getSnapshot(); if ( sn.size()>i && elemType.isSame( sn.get(i), entry ) ) { //a shortcut if its location didn't change! return false; } else { //search for it //note that this code is incorrect for other than one-to-many Iterator olditer = sn.iterator(); while ( olditer.hasNext() ) { Object old = olditer.next(); if ( elemType.isSame( old, entry ) ) return false; } return true; } }
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags"); List sn = (List) getSnapshot(); if ( sn.size()>i && elemType.isSame( sn.get(i), entry ) ) { //a shortcut if its location didn't change! return false; } else { //search for it //note that this code is incorrect for other than one-to-many Iterator olditer = sn.iterator(); while ( olditer.hasNext() ) { Object old = olditer.next(); if ( elemType.isSame( old, entry ) ) return false; } return true; } }
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags"); java.util.List sn = (java.util.List) getSnapshot(); final EntityMode entityMode = getSession().getEntityMode(); if ( sn.size()>i && elemType.isSame( sn.get(i), entry, entityMode ) ) { //a shortcut if its location didn't change! return false; } else { //search for it //note that this code is incorrect for other than one-to-many Iterator olditer = sn.iterator(); while ( olditer.hasNext() ) { Object old = olditer.next(); if ( elemType.isSame( old, entry, entityMode ) ) return false; } return true; } }
public boolean isSame(Object x, Object y, EntityMode entityMode) throws HibernateException { if ( x == y ) return true; if ( x == null || y == null ) return false; Object[] xvalues = getPropertyValues(x, entityMode); Object[] yvalues = getPropertyValues(y, entityMode); for ( int i = 0; i < propertySpan; i++ ) { if ( !propertyTypes[i].isSame( xvalues[i], yvalues[i], entityMode ) ) { return false; } } return true; }
@Override public boolean isSame(Object x, Object y) throws HibernateException { if ( x == y ) { return true; } if ( x == null || y == null ) { return false; } Object[] xvalues = getPropertyValues( x, entityMode ); Object[] yvalues = getPropertyValues( y, entityMode ); for ( int i = 0; i < propertySpan; i++ ) { if ( !propertyTypes[i].isSame( xvalues[i], yvalues[i] ) ) { return false; } } return true; }
public boolean isSame(Object x, Object y, EntityMode entityMode) throws HibernateException { if ( x == y ) { return true; } if ( x == null || y == null ) { return false; } Object[] xvalues = getPropertyValues( x, entityMode ); Object[] yvalues = getPropertyValues( y, entityMode ); for ( int i = 0; i < propertySpan; i++ ) { if ( !propertyTypes[i].isSame( xvalues[i], yvalues[i], entityMode ) ) { return false; } } return true; }
@Override public boolean isSame(Object x, Object y) throws HibernateException { if ( x == y ) { return true; } if ( x == null || y == null ) { return false; } Object[] xvalues = getPropertyValues( x, entityMode ); Object[] yvalues = getPropertyValues( y, entityMode ); for ( int i = 0; i < propertySpan; i++ ) { if ( !propertyTypes[i].isSame( xvalues[i], yvalues[i] ) ) { return false; } } return true; }
public boolean isDirty(Object old, Object current, SessionImplementor session) throws HibernateException { if ( isSame( old, current, session.getEntityMode() ) ) return false; Object oldid = getIdentifier(old, session); Object newid = getIdentifier(current, session); return !getIdentifierType(session).isSame( oldid, newid, session.getEntityMode() ); }