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,
MutableClassDetails classDetails,
XmlDocumentContext xmlDocumentContext) {
if ( jaxbEntity.isCacheable() == Boolean.TRUE ) {
if ( jaxbEntity.isCacheable() != null ) {
final MutableAnnotationUsage<Cacheable> cacheableUsage = classDetails.applyAnnotationUsage(
JpaAnnotations.CACHEABLE,
xmlDocumentContext.getModelBuildingContext()
);
cacheableUsage.setAttributeValue( "value", jaxbEntity.isCacheable() );
classDetails.addAnnotationUsage( cacheableUsage );
}
final JaxbCachingImpl jaxbCaching = jaxbEntity.getCaching();
if ( jaxbCaching != null ) {
final MutableAnnotationUsage<Cache> cacheableUsage = classDetails.applyAnnotationUsage(
final MutableAnnotationUsage<Cache> cacheUsage = classDetails.applyAnnotationUsage(
HibernateAnnotations.CACHE,
xmlDocumentContext.getModelBuildingContext()
);
classDetails.addAnnotationUsage( cacheableUsage );
XmlProcessingHelper.applyAttributeIfSpecified( "region", jaxbCaching.getRegion(), cacheableUsage );
classDetails.addAnnotationUsage( cacheUsage );
XmlProcessingHelper.applyAttributeIfSpecified( "region", jaxbCaching.getRegion(), cacheUsage );
XmlProcessingHelper.applyAttributeIfSpecified(
"usage",
convertCacheAccessType( jaxbCaching.getAccess() ),
cacheableUsage
cacheUsage
);
}
}