HHH-6361 formatting
This commit is contained in:
parent
7bb43baf0b
commit
f9049a1fd2
|
@ -518,8 +518,11 @@ public abstract class CollectionType extends AbstractType implements Association
|
||||||
( ( PersistentCollection ) result ).clearDirty();
|
( ( PersistentCollection ) result ).clearDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemType instanceof AssociationType) {
|
if ( elemType instanceof AssociationType ) {
|
||||||
preserveSnapshot(( PersistentCollection )original, ( PersistentCollection ) result, (AssociationType) elemType, owner, copyCache, session);
|
preserveSnapshot( (PersistentCollection) original,
|
||||||
|
(PersistentCollection) result,
|
||||||
|
(AssociationType) elemType, owner, copyCache,
|
||||||
|
session );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,59 +530,75 @@ public abstract class CollectionType extends AbstractType implements Association
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preserveSnapshot(PersistentCollection original ,PersistentCollection result, AssociationType elemType, Object owner,
|
private void preserveSnapshot(PersistentCollection original,
|
||||||
Map copyCache, SessionImplementor session) {
|
PersistentCollection result, AssociationType elemType,
|
||||||
|
Object owner, Map copyCache, SessionImplementor session) {
|
||||||
Serializable originalSnapshot = original.getStoredSnapshot();
|
Serializable originalSnapshot = original.getStoredSnapshot();
|
||||||
Serializable resultSnapshot = result.getStoredSnapshot();
|
Serializable resultSnapshot = result.getStoredSnapshot();
|
||||||
Serializable targetSnapshot;
|
Serializable targetSnapshot;
|
||||||
|
|
||||||
if (originalSnapshot instanceof List) {
|
if ( originalSnapshot instanceof List ) {
|
||||||
targetSnapshot = new ArrayList(((List) originalSnapshot).size());
|
targetSnapshot = new ArrayList(
|
||||||
for (Object obj : (List) originalSnapshot) {
|
( (List) originalSnapshot ).size() );
|
||||||
((List) targetSnapshot).add(elemType.replace(obj, null, session, owner, copyCache));
|
for ( Object obj : (List) originalSnapshot ) {
|
||||||
|
( (List) targetSnapshot ).add( elemType.replace(
|
||||||
|
obj, null, session, owner, copyCache ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (originalSnapshot instanceof Map) {
|
}
|
||||||
if (originalSnapshot instanceof SortedMap) {
|
else if ( originalSnapshot instanceof Map ) {
|
||||||
targetSnapshot = new TreeMap(((SortedMap) originalSnapshot).comparator());
|
if ( originalSnapshot instanceof SortedMap ) {
|
||||||
} else {
|
targetSnapshot = new TreeMap(
|
||||||
|
( (SortedMap) originalSnapshot ).comparator() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
targetSnapshot = new HashMap(
|
targetSnapshot = new HashMap(
|
||||||
CollectionHelper.determineProperSizing( ((Map) originalSnapshot).size()),
|
CollectionHelper.determineProperSizing(
|
||||||
CollectionHelper.LOAD_FACTOR);
|
( (Map) originalSnapshot ).size() ),
|
||||||
|
CollectionHelper.LOAD_FACTOR );
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<Object, Object> entry : ((Map<Object,Object>) originalSnapshot).entrySet()) {
|
for ( Map.Entry<Object, Object> entry : (
|
||||||
|
(Map<Object, Object>) originalSnapshot ).entrySet() ) {
|
||||||
Object key = entry.getKey();
|
Object key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
Object resultSnapshotValue = (resultSnapshot == null) ? null : ((Map<Object,Object>) resultSnapshot).get(key);
|
Object resultSnapshotValue = ( resultSnapshot == null ) ? null
|
||||||
|
: ( (Map<Object, Object>) resultSnapshot ).get( key );
|
||||||
|
|
||||||
if (key == value) {
|
if ( key == value ) {
|
||||||
Object newValue = elemType.replace(value, resultSnapshotValue, session, owner, copyCache );
|
Object newValue = elemType.replace( value,
|
||||||
((Map) targetSnapshot).put(newValue, newValue);
|
resultSnapshotValue, session, owner, copyCache );
|
||||||
|
( (Map) targetSnapshot ).put( newValue, newValue );
|
||||||
|
|
||||||
} else {
|
}
|
||||||
Object newValue = elemType.replace(value, resultSnapshotValue, session, owner, copyCache );
|
else {
|
||||||
((Map) targetSnapshot).put(key, newValue);
|
Object newValue = elemType.replace( value,
|
||||||
|
resultSnapshotValue, session, owner, copyCache );
|
||||||
|
( (Map) targetSnapshot ).put( key, newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (originalSnapshot instanceof Object []) {
|
}
|
||||||
Object [] arr = ( Object []) originalSnapshot;
|
else if ( originalSnapshot instanceof Object[] ) {
|
||||||
for (int i=0; i< arr.length; i++) {
|
Object[] arr = (Object[]) originalSnapshot;
|
||||||
arr[i] = elemType.replace(arr[i], null, session, owner, copyCache );
|
for ( int i = 0; i < arr.length; i++ ) {
|
||||||
|
arr[i] = elemType.replace(
|
||||||
|
arr[i], null, session, owner, copyCache );
|
||||||
}
|
}
|
||||||
targetSnapshot = originalSnapshot;
|
targetSnapshot = originalSnapshot;
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// retain the same snapshot
|
// retain the same snapshot
|
||||||
targetSnapshot = resultSnapshot;
|
targetSnapshot = resultSnapshot;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(result);
|
CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(
|
||||||
if (ce != null) {
|
result );
|
||||||
ce.resetStoredSnapshot(result, targetSnapshot);
|
if ( ce != null ) {
|
||||||
|
ce.resetStoredSnapshot( result, targetSnapshot );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue