HHH-17049 Bytecode Enhancement, extra records created for associations created in constructor
This commit is contained in:
parent
de3008e712
commit
3ef251dfb2
|
@ -86,11 +86,16 @@ public final class Cascade {
|
|||
LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() );
|
||||
}
|
||||
final PersistenceContext persistenceContext = eventSource.getPersistenceContextInternal();
|
||||
|
||||
final EntityEntry entry = persistenceContext.getEntry( parent );
|
||||
if ( entry != null && entry.getLoadedState() == null && entry.getStatus() == Status.MANAGED && persister.getBytecodeEnhancementMetadata()
|
||||
.isEnhancedForLazyLoading() ) {
|
||||
return;
|
||||
}
|
||||
final Type[] types = persister.getPropertyTypes();
|
||||
final String[] propertyNames = persister.getPropertyNames();
|
||||
final CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
|
||||
final boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent );
|
||||
|
||||
for ( int i = 0; i < types.length; i++) {
|
||||
final CascadeStyle style = cascadeStyles[ i ];
|
||||
final String propertyName = propertyNames[ i ];
|
||||
|
@ -108,7 +113,7 @@ public final class Cascade {
|
|||
// If parent is a detached entity being merged,
|
||||
// then parent will not be in the PersistenceContext
|
||||
// (so lazy attributes must not be initialized).
|
||||
if ( persistenceContext.getEntry( parent ) == null ) {
|
||||
if ( entry == null ) {
|
||||
// parent was not in the PersistenceContext
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -148,9 +148,9 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
|
|||
|
||||
private static boolean flushable(EntityEntry entry) {
|
||||
final Status status = entry.getStatus();
|
||||
return ( status == Status.MANAGED && entry.getLoadedState() != null )
|
||||
|| status == Status.SAVING
|
||||
|| status == Status.READ_ONLY;
|
||||
return status == Status.MANAGED
|
||||
|| status == Status.SAVING
|
||||
|| status == Status.READ_ONLY;
|
||||
}
|
||||
|
||||
private void cascadeOnFlush(EventSource session, EntityPersister persister, Object object, PersistContext anything)
|
||||
|
|
Loading…
Reference in New Issue