@Override public Object getSnapshotElement(Object entry, int i) { final List sn = (List) getSnapshot(); return sn.get( i ); }
@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 equalsSnapshot(CollectionPersister persister) throws HibernateException { final Type elementType = persister.getElementType(); final List sn = (List) getSnapshot(); if ( sn.size() != bag.size() ) { return false; } for ( Object elt : bag ) { final boolean unequal = countOccurrences( elt, bag, elementType ) != countOccurrences( elt, sn, elementType ); if ( unequal ) { return false; } } return true; }
final Type elementType = persister.getElementType(); final ArrayList deletes = new ArrayList(); final List sn = (List) getSnapshot(); final Iterator olditer = sn.iterator(); int i=0;
@Override @SuppressWarnings("unchecked") public E getSnapshotElement(Object entry, int index) { final List sn = (List) getSnapshot(); return (E) sn.get( index ); }
public Object getSnapshotElement(Object entry, int i) { List sn = (List) getSnapshot(); return sn.get(i); }
public Object getSnapshotElement(Object entry, int i) { List sn = (List) getSnapshot(); return sn.get(i); }
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; } }
@Override public boolean equalsSnapshot(PersistentCollectionDescriptor collectionDescriptor) throws HibernateException { final List sn = (List) getSnapshot(); if ( sn.size() != bag.size() ) { return false; } for ( Object elt : bag ) { final boolean unequal = countOccurrences( elt, bag ) != countOccurrences( elt, sn ); if ( unequal ) { 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 equalsSnapshot(CollectionPersister persister) throws HibernateException { Type elementType = persister.getElementType(); List sn = (List) getSnapshot(); if ( sn.size()!=bag.size() ) return false; for ( Object elt : bag ) { final boolean unequal = countOccurrences( elt, bag, elementType ) != countOccurrences( elt, sn, elementType ); if ( unequal ) { return false; } } return true; }
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { Type elementType = persister.getElementType(); List sn = (List) getSnapshot(); if ( sn.size()!=bag.size() ) return false; for ( Object elt : bag ) { final boolean unequal = countOccurrences( elt, bag, elementType ) != countOccurrences( elt, sn, elementType ); if ( unequal ) { return false; } } return true; }
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException { //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags"); Type elementType = persister.getElementType(); ArrayList deletes = new ArrayList(); List sn = (List) getSnapshot(); Iterator olditer = sn.iterator(); int i=0; while ( olditer.hasNext() ) { Object old = olditer.next(); Iterator newiter = bag.iterator(); boolean found = false; if ( bag.size()>i && elementType.isSame( old, bag.get(i++) ) ) { //a shortcut if its location didn't change! found = true; } else { //search for it //note that this code is incorrect for other than one-to-many while ( newiter.hasNext() ) { if ( elementType.isSame( old, newiter.next() ) ) { found = true; break; } } } if (!found) deletes.add(old); } return deletes.iterator(); }
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException { //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags"); Type elementType = persister.getElementType(); ArrayList deletes = new ArrayList(); List sn = (List) getSnapshot(); Iterator olditer = sn.iterator(); int i=0; while ( olditer.hasNext() ) { Object old = olditer.next(); Iterator newiter = bag.iterator(); boolean found = false; if ( bag.size()>i && elementType.isSame( old, bag.get(i++) ) ) { //a shortcut if its location didn't change! found = true; } else { //search for it //note that this code is incorrect for other than one-to-many while ( newiter.hasNext() ) { if ( elementType.isSame( old, newiter.next() ) ) { found = true; break; } } } if (!found) deletes.add(old); } return deletes.iterator(); }
@Override @SuppressWarnings("unchecked") public Iterator getDeletes(PersistentCollectionDescriptor descriptor, boolean indexIsFormula) throws HibernateException { final ArrayList<E> deletes = new ArrayList<>(); final List<E> sn = (List<E>) getSnapshot(); int i=0; for ( E old : sn ) { boolean found = false; if ( bag.size() > i && getCollectionDescriptor().getElementDescriptor().getJavaTypeDescriptor().areEqual( old, bag.get( i++ ) ) ) { //a shortcut if its location didn't change! found = true; } else { //search for it //note that this code is incorrect for other than one-to-many for ( E aBag : bag ) { if ( getCollectionDescriptor().getElementDescriptor().getJavaTypeDescriptor().areEqual( old, aBag ) ) { found = true; break; } } } if ( !found ) { deletes.add( old ); } } return deletes.iterator(); }
@Override @SuppressWarnings("unchecked") public boolean needsInserting(Object entry, int i) throws HibernateException { final List<E> sn = (List<E>) getSnapshot(); if ( sn.size() > i && getCollectionDescriptor().getElementDescriptor().getJavaTypeDescriptor().areEqual( sn.get( i ), (E) 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 ( E old : sn ) { if ( getCollectionDescriptor().getElementDescriptor().getJavaTypeDescriptor().areEqual( old, (E) entry ) ) { return false; } } return true; } }