/** * JDK serialization hook for serializing * * @param oos The stream to write ourselves to * * @throws IOException Indicates an IO exception accessing the given stream */ public void serialize(ObjectOutputStream oos) throws IOException { log.tracef( "Starting serialization of [%s] EntityEntry entries", count ); oos.writeInt( count ); if ( count == 0 ) { return; } ManagedEntity managedEntity = head; while ( managedEntity != null ) { // so we know whether or not to build a ManagedEntityImpl on deserialize oos.writeBoolean( managedEntity == managedEntity.$$_hibernate_getEntityInstance() ); oos.writeObject( managedEntity.$$_hibernate_getEntityInstance() ); // we need to know which implementation of EntityEntry is being serialized oos.writeInt( managedEntity.$$_hibernate_getEntityEntry().getClass().getName().length() ); oos.writeChars( managedEntity.$$_hibernate_getEntityEntry().getClass().getName() ); managedEntity.$$_hibernate_getEntityEntry().serialize( oos ); managedEntity = managedEntity.$$_hibernate_getNextManagedEntity(); } }
assertNotNull( managedParent.$$_hibernate_getEntityInstance() ); assertNotNull( managedParent.$$_hibernate_getEntityEntry() ); assertNull( managedParent.$$_hibernate_getPreviousManagedEntity() ); assertNotNull( managedParent.$$_hibernate_getEntityInstance() ); assertNull( managedParent.$$_hibernate_getEntityEntry() ); assertNull( managedParent.$$_hibernate_getPreviousManagedEntity() ); assertNotNull( managedParent.$$_hibernate_getEntityInstance() ); assertNull( managedParent.$$_hibernate_getEntityEntry() ); assertNull( managedParent.$$_hibernate_getPreviousManagedEntity() );
/** * JDK serialization hook for serializing * * @param oos The stream to write ourselves to * * @throws IOException Indicates an IO exception accessing the given stream */ public void serialize(ObjectOutputStream oos) throws IOException { log.tracef( "Starting serialization of [%s] EntityEntry entries", count ); oos.writeInt( count ); if ( count == 0 ) { return; } ManagedEntity managedEntity = head; while ( managedEntity != null ) { // so we know whether or not to build a ManagedEntityImpl on deserialize oos.writeBoolean( managedEntity == managedEntity.$$_hibernate_getEntityInstance() ); oos.writeObject( managedEntity.$$_hibernate_getEntityInstance() ); // we need to know which implementation of EntityEntry is being serialized oos.writeInt( managedEntity.$$_hibernate_getEntityEntry().getClass().getName().length() ); oos.writeChars( managedEntity.$$_hibernate_getEntityEntry().getClass().getName() ); managedEntity.$$_hibernate_getEntityEntry().serialize( oos ); managedEntity = managedEntity.$$_hibernate_getNextManagedEntity(); } }
/** * The main bugaboo with IdentityMap that warranted this class in the first place. * * Return an array of all the entity/EntityEntry pairs in this context. The array is to make sure * that the iterators built off of it are safe from concurrency/reentrancy * * @return The safe array */ public Map.Entry<Object, EntityEntry>[] reentrantSafeEntityEntries() { if ( dirty ) { reentrantSafeEntries = new EntityEntryCrossRefImpl[count]; int i = 0; ManagedEntity managedEntity = head; while ( managedEntity != null ) { reentrantSafeEntries[i++] = new EntityEntryCrossRefImpl( managedEntity.$$_hibernate_getEntityInstance(), managedEntity.$$_hibernate_getEntityEntry() ); managedEntity = managedEntity.$$_hibernate_getNextManagedEntity(); } dirty = false; } return reentrantSafeEntries; }
@Override public Object $$_hibernate_getEntityInstance() { return managedEntity.$$_hibernate_getEntityInstance(); }
/** * The main bugaboo with IdentityMap that warranted this class in the first place. * * Return an array of all the entity/EntityEntry pairs in this context. The array is to make sure * that the iterators built off of it are safe from concurrency/reentrancy * * @return The safe array */ public Map.Entry<Object, EntityEntry>[] reentrantSafeEntityEntries() { if ( dirty ) { reentrantSafeEntries = new EntityEntryCrossRefImpl[count]; int i = 0; ManagedEntity managedEntity = head; while ( managedEntity != null ) { reentrantSafeEntries[i++] = new EntityEntryCrossRefImpl( managedEntity.$$_hibernate_getEntityInstance(), managedEntity.$$_hibernate_getEntityEntry() ); managedEntity = managedEntity.$$_hibernate_getNextManagedEntity(); } dirty = false; } return reentrantSafeEntries; }
@Override public Object $$_hibernate_getEntityInstance() { return managedEntity.$$_hibernate_getEntityInstance(); }