HHH-18041 With SharedCacheMode.DISABLE_SELECTIVE entities with cacheable false should not be cached

This commit is contained in:
Andrea Boriero 2024-04-30 21:31:07 +02:00 committed by Steve Ebersole
parent b894a8d228
commit 7b10051a75
1 changed files with 7 additions and 5 deletions

View File

@ -586,26 +586,28 @@ public class ManagedTypeProcessor {
JaxbEntityImpl jaxbEntity, JaxbEntityImpl jaxbEntity,
MutableClassDetails classDetails, MutableClassDetails classDetails,
XmlDocumentContext xmlDocumentContext) { XmlDocumentContext xmlDocumentContext) {
if ( jaxbEntity.isCacheable() == Boolean.TRUE ) { if ( jaxbEntity.isCacheable() != null ) {
final MutableAnnotationUsage<Cacheable> cacheableUsage = classDetails.applyAnnotationUsage( final MutableAnnotationUsage<Cacheable> cacheableUsage = classDetails.applyAnnotationUsage(
JpaAnnotations.CACHEABLE, JpaAnnotations.CACHEABLE,
xmlDocumentContext.getModelBuildingContext() xmlDocumentContext.getModelBuildingContext()
); );
cacheableUsage.setAttributeValue( "value", jaxbEntity.isCacheable() );
classDetails.addAnnotationUsage( cacheableUsage ); classDetails.addAnnotationUsage( cacheableUsage );
} }
final JaxbCachingImpl jaxbCaching = jaxbEntity.getCaching(); final JaxbCachingImpl jaxbCaching = jaxbEntity.getCaching();
if ( jaxbCaching != null ) { if ( jaxbCaching != null ) {
final MutableAnnotationUsage<Cache> cacheableUsage = classDetails.applyAnnotationUsage( final MutableAnnotationUsage<Cache> cacheUsage = classDetails.applyAnnotationUsage(
HibernateAnnotations.CACHE, HibernateAnnotations.CACHE,
xmlDocumentContext.getModelBuildingContext() xmlDocumentContext.getModelBuildingContext()
); );
classDetails.addAnnotationUsage( cacheableUsage ); classDetails.addAnnotationUsage( cacheUsage );
XmlProcessingHelper.applyAttributeIfSpecified( "region", jaxbCaching.getRegion(), cacheableUsage ); XmlProcessingHelper.applyAttributeIfSpecified( "region", jaxbCaching.getRegion(), cacheUsage );
XmlProcessingHelper.applyAttributeIfSpecified( XmlProcessingHelper.applyAttributeIfSpecified(
"usage", "usage",
convertCacheAccessType( jaxbCaching.getAccess() ), convertCacheAccessType( jaxbCaching.getAccess() ),
cacheableUsage cacheUsage
); );
} }
} }