private boolean isCollectionDirtyCheckNecessary(EntityPersister persister, Status status) { return ( status == Status.MANAGED || status == Status.READ_ONLY ) && persister.isVersioned() && persister.hasCollections(); }
private boolean wrapCollections( EventSource session, EntityPersister persister, Type[] types, Object[] values ) { if ( persister.hasCollections() ) { // wrap up any new collections directly referenced by the object // or its components // NOTE: we need to do the wrap here even if its not "dirty", // because collections need wrapping but changes to _them_ // don't dirty the container. Also, for versioned data, we // need to wrap before calling searchForDirtyCollections WrapVisitor visitor = new WrapVisitor( session ); // substitutes into values by side-effect visitor.processEntityPropertyValues( values, types ); return visitor.isSubstitutionRequired(); } else { return false; } }
@SuppressWarnings( {"SimplifiableIfStatement"}) private boolean isUnequivocallyNonDirty(Object entity) { if ( entity instanceof SelfDirtinessTracker ) { return ! persister.hasCollections() && ! ( (SelfDirtinessTracker) entity ).$$_hibernate_hasDirtyAttributes(); } final CustomEntityDirtinessStrategy customEntityDirtinessStrategy = getPersistenceContext().getSession().getFactory().getCustomEntityDirtinessStrategy(); if ( customEntityDirtinessStrategy.canDirtyCheck( entity, getPersister(), (Session) getPersistenceContext().getSession() ) ) { return ! customEntityDirtinessStrategy.isDirty( entity, getPersister(), (Session) getPersistenceContext().getSession() ); } if ( getPersister().hasMutableProperties() ) { return false; } return false; }
if ( persister.hasCollections() ) { substitute = substitute || visitCollectionsBeforeSave( entity, id, values, types, source );
if ( persister.hasCollections() ) { new EvictVisitor( session, object ).process( object, persister );
if ( persister.hasCollections() ) { new FlushVisitor( session, entity ).processEntityPropertyValues( values, types );
final EntityKey key = source.generateEntityKey( id, persister ); source.getPersistenceContext().removeEntity( key ); if ( persister.hasCollections() ) { new EvictVisitor( source, object ).process( object, persister );
@Override public boolean hasCollections() { return persister.hasCollections(); }
private boolean isCollectionDirtyCheckNecessary(EntityPersister persister, Status status) { return status==Status.MANAGED && persister.isVersioned() && persister.hasCollections(); }
private boolean isCollectionDirtyCheckNecessary(EntityPersister persister, Status status) { return ( status == Status.MANAGED || status == Status.READ_ONLY ) && persister.isVersioned() && persister.hasCollections(); }
private boolean isCollectionDirtyCheckNecessary(EntityPersister persister, Status status) { return ( status == Status.MANAGED || status == Status.READ_ONLY ) && persister.isVersioned() && persister.hasCollections(); }
protected void doEvict( final Object object, final EntityKey key, final EntityPersister persister, final SessionImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "evicting " + MessageHelper.infoString(persister) ); } // remove all collections for the entity from the session-level cache if ( persister.hasCollections() ) new EvictVisitor( session ).process( object, persister ); // remove any snapshot, not really for memory management purposes, but // rather because it might now be stale, and there is no longer any // EntityEntry to take precedence // This is now handled by removeEntity() //session.getPersistenceContext().removeDatabaseSnapshot(key); Cascades.cascade(session, persister, object, Cascades.ACTION_EVICT, Cascades.CASCADE_AFTER_EVICT); } }
protected void doEvict( final Object object, final EntityKey key, final EntityPersister persister, final EventSource session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "evicting " + MessageHelper.infoString(persister) ); } // remove all collections for the entity from the session-level cache if ( persister.hasCollections() ) { new EvictVisitor( session ).process( object, persister ); } new Cascade( CascadingAction.EVICT, Cascade.AFTER_EVICT, session ) .cascade( persister, object ); } }
private boolean wrapCollections( EventSource session, EntityPersister persister, Type[] types, Object[] values ) { if ( persister.hasCollections() ) { // wrap up any new collections directly referenced by the object // or its components // NOTE: we need to do the wrap here even if its not "dirty", // because collections need wrapping but changes to _them_ // don't dirty the container. Also, for versioned data, we // need to wrap before calling searchForDirtyCollections WrapVisitor visitor = new WrapVisitor(session); // substitutes into values by side-effect visitor.processEntityPropertyValues(values, types); return visitor.isSubstitutionRequired(); } else { return false; } }
private boolean wrapCollections( EventSource session, EntityPersister persister, Type[] types, Object[] values ) { if ( persister.hasCollections() ) { // wrap up any new collections directly referenced by the object // or its components // NOTE: we need to do the wrap here even if its not "dirty", // because collections need wrapping but changes to _them_ // don't dirty the container. Also, for versioned data, we // need to wrap before calling searchForDirtyCollections WrapVisitor visitor = new WrapVisitor(session); // substitutes into values by side-effect visitor.processEntityPropertyValues(values, types); return visitor.isSubstitutionRequired(); } else { return false; } }
private boolean wrapCollections( EventSource session, EntityPersister persister, Type[] types, Object[] values ) { if ( persister.hasCollections() ) { // wrap up any new collections directly referenced by the object // or its components // NOTE: we need to do the wrap here even if its not "dirty", // because collections need wrapping but changes to _them_ // don't dirty the container. Also, for versioned data, we // need to wrap before calling searchForDirtyCollections WrapVisitor visitor = new WrapVisitor(session); // substitutes into values by side-effect visitor.processEntityPropertyValues(values, types); return visitor.isSubstitutionRequired(); } else { return false; } }
protected void doEvict( final Object object, final EntityKey key, final EntityPersister persister, final EventSource session) throws HibernateException { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Evicting {0}", MessageHelper.infoString( persister ) ); } // remove all collections for the entity from the session-level cache if ( persister.hasCollections() ) { new EvictVisitor( session ).process( object, persister ); } // remove any snapshot, not really for memory management purposes, but // rather because it might now be stale, and there is no longer any // EntityEntry to take precedence // This is now handled by removeEntity() //session.getPersistenceContext().removeDatabaseSnapshot(key); new Cascade( CascadingAction.EVICT, Cascade.AFTER_EVICT, session ) .cascade( persister, object ); } }
protected void doEvict( final Object object, final EntityKey key, final EntityPersister persister, final EventSource session) throws HibernateException { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Evicting {0}", MessageHelper.infoString( persister ) ); } // remove all collections for the entity from the session-level cache if ( persister.hasCollections() ) { new EvictVisitor( session ).process( object, persister ); } // remove any snapshot, not really for memory management purposes, but // rather because it might now be stale, and there is no longer any // EntityEntry to take precedence // This is now handled by removeEntity() //session.getPersistenceContext().removeDatabaseSnapshot(key); new Cascade( CascadingAction.EVICT, Cascade.AFTER_EVICT, session ) .cascade( persister, object ); } }
/** * Flushes a single entity's state to the database, by scheduling * an update action, if necessary */ public void onFlushEntity(FlushEntityEvent event) throws HibernateException { final Object entity = event.getEntity(); final EntityEntry entry = event.getEntityEntry(); final EventSource session = event.getSession(); final EntityPersister persister = entry.getPersister(); final Status status = entry.getStatus(); final Type[] types = persister.getPropertyTypes(); final boolean mightBeDirty = entry.requiresDirtyCheck(entity); final Object[] values = getValues( entity, entry, mightBeDirty, session ); event.setPropertyValues(values); //TODO: avoid this for non-new instances where mightBeDirty==false boolean substitute = wrapCollections( session, persister, types, values); if ( isUpdateNecessary( event, mightBeDirty ) ) { substitute = scheduleUpdate( event ) || substitute; } if ( status != Status.DELETED ) { // now update the object .. has to be outside the main if block above (because of collections) if (substitute) persister.setPropertyValues( entity, values ); // Search for collections by reachability, updating their role. // We don't want to touch collections reachable from a deleted object if ( persister.hasCollections() ) { new FlushVisitor(session, entity).processEntityPropertyValues(values, types); } } }
status==Status.MANAGED && persister.isVersioned() && persister.hasCollections() ) { DirtyCollectionSearchVisitor visitor = new DirtyCollectionSearchVisitor(