HHH-17049 Bytecode Enhancement, extra records created for associations created in constructor
(cherry picked from commit 3ef251dfb2
)
This commit is contained in:
parent
ad55143eb5
commit
5e17e121ef
|
@ -87,11 +87,16 @@ public final class Cascade {
|
||||||
LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() );
|
LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() );
|
||||||
}
|
}
|
||||||
final PersistenceContext persistenceContext = eventSource.getPersistenceContextInternal();
|
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 Type[] types = persister.getPropertyTypes();
|
||||||
final String[] propertyNames = persister.getPropertyNames();
|
final String[] propertyNames = persister.getPropertyNames();
|
||||||
final CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
|
final CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
|
||||||
final boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent );
|
final boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent );
|
||||||
|
|
||||||
for ( int i = 0; i < types.length; i++) {
|
for ( int i = 0; i < types.length; i++) {
|
||||||
final CascadeStyle style = cascadeStyles[ i ];
|
final CascadeStyle style = cascadeStyles[ i ];
|
||||||
final String propertyName = propertyNames[ i ];
|
final String propertyName = propertyNames[ i ];
|
||||||
|
@ -109,7 +114,7 @@ public final class Cascade {
|
||||||
// If parent is a detached entity being merged,
|
// If parent is a detached entity being merged,
|
||||||
// then parent will not be in the PersistenceContext
|
// then parent will not be in the PersistenceContext
|
||||||
// (so lazy attributes must not be initialized).
|
// (so lazy attributes must not be initialized).
|
||||||
if ( persistenceContext.getEntry( parent ) == null ) {
|
if ( entry == null ) {
|
||||||
// parent was not in the PersistenceContext
|
// parent was not in the PersistenceContext
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,9 +139,8 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
|
||||||
//safe from concurrent modification because of how concurrentEntries() is implemented on IdentityMap
|
//safe from concurrent modification because of how concurrentEntries() is implemented on IdentityMap
|
||||||
for ( Map.Entry<Object,EntityEntry> me : persistenceContext.reentrantSafeEntityEntries() ) {
|
for ( Map.Entry<Object,EntityEntry> me : persistenceContext.reentrantSafeEntityEntries() ) {
|
||||||
// for ( Map.Entry me : IdentityMap.concurrentEntries( persistenceContext.getEntityEntries() ) ) {
|
// for ( Map.Entry me : IdentityMap.concurrentEntries( persistenceContext.getEntityEntries() ) ) {
|
||||||
EntityEntry entry = me.getValue();
|
final EntityEntry entry = me.getValue();
|
||||||
Status status = entry.getStatus();
|
if ( flushable( entry ) ) {
|
||||||
if ( status == Status.MANAGED || status == Status.SAVING || status == Status.READ_ONLY ) {
|
|
||||||
cascadeOnFlush( session, entry.getPersister(), me.getKey(), context );
|
cascadeOnFlush( session, entry.getPersister(), me.getKey(), context );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +148,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
|
||||||
|
|
||||||
private static boolean flushable(EntityEntry entry) {
|
private static boolean flushable(EntityEntry entry) {
|
||||||
final Status status = entry.getStatus();
|
final Status status = entry.getStatus();
|
||||||
return ( status == Status.MANAGED && entry.getLoadedState() != null )
|
return status == Status.MANAGED
|
||||||
|| status == Status.SAVING
|
|| status == Status.SAVING
|
||||||
|| status == Status.READ_ONLY;
|
|| status == Status.READ_ONLY;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue