mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-07 19:58:16 +00:00
HHH-13377 Lazy loaded properties of bytecode enhanced entity are left stale after refresh of entity
This commit is contained in:
parent
ad5855f4b1
commit
4ebbf5b36d
@ -198,4 +198,8 @@ public void addLazyFieldByGraph(String fieldName) {
|
|||||||
}
|
}
|
||||||
mutableLazyFields.add( fieldName );
|
mutableLazyFields.add( fieldName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearInitializedLazyFields() {
|
||||||
|
initializedLazyFields = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
import org.hibernate.NonUniqueObjectException;
|
import org.hibernate.NonUniqueObjectException;
|
||||||
import org.hibernate.TransientObjectException;
|
import org.hibernate.TransientObjectException;
|
||||||
import org.hibernate.UnresolvableObjectException;
|
import org.hibernate.UnresolvableObjectException;
|
||||||
|
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
|
||||||
|
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
|
||||||
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
||||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||||
import org.hibernate.cache.spi.access.SoftLock;
|
import org.hibernate.cache.spi.access.SoftLock;
|
||||||
@ -189,6 +191,14 @@ private static void refresh(
|
|||||||
EntityEntry entry,
|
EntityEntry entry,
|
||||||
Object id,
|
Object id,
|
||||||
PersistenceContext persistenceContext) {
|
PersistenceContext persistenceContext) {
|
||||||
|
final BytecodeEnhancementMetadata instrumentationMetadata = persister.getInstrumentationMetadata();
|
||||||
|
if ( object != null && instrumentationMetadata.isEnhancedForLazyLoading() ) {
|
||||||
|
final LazyAttributeLoadingInterceptor interceptor = instrumentationMetadata.extractInterceptor( object );
|
||||||
|
if ( interceptor != null ) {
|
||||||
|
// The list of initialized lazy fields have to be cleared in order to refresh them from the database.
|
||||||
|
interceptor.clearInitializedLazyFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Object result = source.getLoadQueryInfluencers().fromInternalFetchProfile(
|
final Object result = source.getLoadQueryInfluencers().fromInternalFetchProfile(
|
||||||
CascadingFetchProfile.REFRESH,
|
CascadingFetchProfile.REFRESH,
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import org.hibernate.annotations.Formula;
|
import org.hibernate.annotations.Formula;
|
||||||
import org.hibernate.dialect.MariaDBDialect;
|
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
|
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
|
||||||
@ -44,8 +43,7 @@
|
|||||||
@BytecodeEnhanced
|
@BytecodeEnhanced
|
||||||
@SkipForDialectGroup(
|
@SkipForDialectGroup(
|
||||||
{
|
{
|
||||||
@SkipForDialect( dialectClass = MySQLDialect.class, reason = "does not support || as String concatenation"),
|
@SkipForDialect( dialectClass = MySQLDialect.class, matchSubTypes = true, reason = "does not support || as String concatenation"),
|
||||||
@SkipForDialect( dialectClass = MariaDBDialect.class, reason = "does not support || as String concatenation"),
|
|
||||||
@SkipForDialect( dialectClass = SQLServerDialect.class, reason = "does not support || as String concatenation"),
|
@SkipForDialect( dialectClass = SQLServerDialect.class, reason = "does not support || as String concatenation"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user