id,
source.getFactory()
)
);
}
final EntityKey key = source.generateEntityKey( id, persister );
if ( source.getPersistenceContext().getEntry( key ) != null ) {
throw new PersistentObjectException(
"attempted to refresh transient instance when persistent instance was already associated with the Session: " +
MessageHelper.infoString( persister, id, source.getFactory() )
);
}
}
else {
if ( LOG.isTraceEnabled() ) {
LOG.tracev(
"Refreshing ", MessageHelper.infoString(
e.getPersister(),
e.getId(),
source.getFactory()
)
);
}
if ( !e.isExistsInDatabase() ) {
throw new UnresolvableObjectException(
e.getId(),
"this instance does not yet exist as a row in the database"
);
}
persister = e.getPersister();
id = e.getId();
}
// cascade the refresh prior to refreshing this entity
refreshedAlready.put( object, object );
new Cascade( CascadingActions.REFRESH, CascadePoint.BEFORE_REFRESH, source ).cascade(
persister,
object,
refreshedAlready
);
if ( e != null ) {
final EntityKey key = source.generateEntityKey( id, persister );
source.getPersistenceContext().removeEntity( key );
if ( persister.hasCollections() ) {
new EvictVisitor( source ).process( object, persister );
}
}