@Override public Serializable getSnapshot(PersistentCollection coll) { return getCollectionEntry( coll ).getSnapshot(); }
@Override public void onPreUpdateCollection(PreCollectionUpdateEvent event) { final CollectionEntry collectionEntry = getCollectionEntry( event ); if ( !collectionEntry.getLoadedPersister().isInverse() ) { onCollectionAction( event, event.getCollection(), collectionEntry.getSnapshot(), collectionEntry ); } else { onCollectionActionInversed( event, event.getCollection(), collectionEntry.getSnapshot(), collectionEntry ); } } }
public void addEvent(AbstractCollectionEvent event, Listener listener) { CollectionEntry collectionEntry = event.getSession() .getPersistenceContext() .getCollectionEntry(event.getCollection()); Serializable snapshot = collectionEntry.getSnapshot(); log.debug("add Event: " + event.getClass() + "; listener = " + listener.getClass() + "; snapshot = " + snapshot); listenersCalled.add(listener); events.add(event); snapshots.add(snapshot); }
public boolean isSnapshotEmpty(PersistentCollection collection) { //TODO: does this really need to be here? // does the collection already have // it's own up-to-date snapshot? return collection.wasInitialized() && ( getLoadedPersister()==null || getLoadedPersister().isMutable() ) && collection.isSnapshotEmpty( getSnapshot() ); }
@Override public void onPreRemoveCollection(PreCollectionRemoveEvent event) { final CollectionEntry collectionEntry = getCollectionEntry( event ); if ( collectionEntry != null ) { if ( !collectionEntry.getLoadedPersister().isInverse() ) { Serializable oldColl = collectionEntry.getSnapshot(); if ( !event.getCollection().wasInitialized() && shouldGenerateRevision( event ) ) { // In case of uninitialized collection we need a fresh snapshot to properly calculate audit data. oldColl = initializeCollection( event ); } onCollectionAction( event, null, oldColl, collectionEntry ); } else { // HHH-7510 - Avoid LazyInitializationException when global_with_modified_flag = true if ( getEnversService().getGlobalConfiguration().isGlobalWithModifiedFlag() ) { initializeCollection( event ); } } } } }
/** * Get the snapshot of the pre-flush collection state */ @Override public Serializable getSnapshot(PersistentCollection coll) { return getCollectionEntry(coll).getSnapshot(); }
@Override public Serializable getSnapshot(PersistentCollection coll) { return getCollectionEntry( coll ).getSnapshot(); }
/** * Get the snapshot of the pre-flush collection state */ @Override public Serializable getSnapshot(PersistentCollection coll) { return getCollectionEntry(coll).getSnapshot(); }
@Override public void onPreUpdateCollection(PreCollectionUpdateEvent event) { final CollectionEntry collectionEntry = getCollectionEntry( event ); if ( !collectionEntry.getLoadedCollectionDescriptor().isInverse() ) { onCollectionAction( event, event.getCollection(), collectionEntry.getSnapshot(), collectionEntry ); } else { onCollectionActionInversed( event, event.getCollection(), collectionEntry.getSnapshot(), collectionEntry ); } } }
public boolean isSnapshotEmpty(PersistentCollection collection) { //TODO: does this really need to be here? // does the collection already have // it's own up-to-date snapshot? return collection.wasInitialized() && ( getLoadedPersister()==null || getLoadedPersister().isMutable() ) && collection.isSnapshotEmpty( getSnapshot() ); }
public boolean isSnapshotEmpty(PersistentCollection collection) { //TODO: does this really need to be here? // does the collection already have // it's own up-to-date snapshot? return collection.wasInitialized() && ( getLoadedPersister()==null || getLoadedPersister().isMutable() ) && collection.isSnapshotEmpty( getSnapshot() ); }
Serializable oldColl = collectionEntry.getSnapshot();
public boolean isSnapshotEmpty(PersistentCollection collection) { //TODO: does this really need to be here? // does the collection already have // it's own up-to-date snapshot? return collection.wasInitialized() && ( getLoadedCollectionDescriptor() == null || getLoadedCollectionDescriptor().getMutabilityPlan().isMutable() ) && collection.isSnapshotEmpty( getSnapshot() ); }
private void cascadeOrphans(JPABase base, PersistentCollection persistentCollection, boolean willBeSaved) { String dbName = JPA.getDBName(this.getClass()); SessionImpl session = ((SessionImpl) JPA.em(dbName).getDelegate()); PersistenceContext pc = session.getPersistenceContext(); CollectionEntry ce = pc.getCollectionEntry(persistentCollection); if (ce != null) { CollectionPersister cp = ce.getLoadedPersister(); if (cp != null) { Type ct = cp.getElementType(); if (ct instanceof EntityType) { EntityEntry entry = pc.getEntry(base); String entityName = entry.getEntityName(); entityName = ((EntityType) ct).getAssociatedEntityName(session.getFactory()); if (ce.getSnapshot() != null) { Collection orphans = ce.getOrphans(entityName, persistentCollection); for (Object o : orphans) { saveAndCascadeIfJPABase(o, willBeSaved); } } } } } }
@Override public void onPreRemoveCollection(PreCollectionRemoveEvent event) { final CollectionEntry collectionEntry = getCollectionEntry( event ); if ( collectionEntry != null ) { if ( !collectionEntry.getLoadedCollectionDescriptor().isInverse() ) { Serializable oldColl = collectionEntry.getSnapshot(); if ( !event.getCollection().wasInitialized() && shouldGenerateRevision( event ) ) { // In case of uninitialized collection we need a fresh snapshot to properly calculate audit data. oldColl = initializeCollection( event ); } onCollectionAction( event, null, oldColl, collectionEntry ); } else { // HHH-7510 - Avoid LazyInitializationException when global_with_modified_flag = true if ( getAuditService().getOptions().isGlobalWithModifiedFlagEnabled() ) { initializeCollection( event ); } } } } }