Skip to content

Commit

Permalink
Merge pull request wildfly#18152 from scottmarlow/WFLY-19664_warnifca…
Browse files Browse the repository at this point in the history
…cheregionspecified

WFLY-19664 Log warning if hibernate.cache.region.factory_class setting is ignored
  • Loading branch information
bstansberry authored Aug 28, 2024
2 parents b6f95c3 + ef68dce commit ea53695
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.jboss.as.jpa.hibernate;

import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;

import org.hibernate.boot.archive.spi.ArchiveException;
import org.jboss.logging.BasicLogger;
Expand Down Expand Up @@ -46,6 +47,10 @@ public interface JpaLogger extends BasicLogger {
@Message(id = 20261, value = "Hibernate ORM did not register LifeCycleListener")
IllegalStateException HibernateORMDidNotRegisterLifeCycleListener();

@LogMessage(level = WARN)
@Message(id = 20262, value = "Application custom cache region setting is ignored %s=%s")
void ignoredCacheRegionSetting(String propertyName, String setting );

/**
* Creates an exception indicating application is setting persistence unit property "hibernate.id.new_generator_mappings" to
* false which indicates that the old ID generator should be used, however Hibernate ORM 6 does not include the old ID generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) {

final Object regionFactoryInitiatorEnabled = serviceRegistryBuilder.getSettings().getOrDefault(CONTROL2LCINTEGRATION, true);
final Object regionFactory = serviceRegistryBuilder.getSettings().get(HIBERNATE_REGION_FACTORY_CLASS);
if ((regionFactory instanceof String) && ((String) regionFactory).contains(EHCACHE)) {
JPA_LOGGER.tracef("ServiceContributorImpl#contribute application is using Ehcache via regionFactory=%s",
regionFactory);
} else if (regionFactoryInitiatorEnabled == null ||
if ((regionFactory instanceof String)) {
String cacheRegionFactory = (String) regionFactory;
if (cacheRegionFactory.contains(EHCACHE)) {
JPA_LOGGER.tracef("ServiceContributorImpl#contribute application is using Ehcache via %s=%s",
HIBERNATE_REGION_FACTORY_CLASS, cacheRegionFactory);
return;
} else {
// warn and ignore application cache region setting
JPA_LOGGER.ignoredCacheRegionSetting(HIBERNATE_REGION_FACTORY_CLASS, cacheRegionFactory);
}
}
if (regionFactoryInitiatorEnabled == null ||
(regionFactoryInitiatorEnabled instanceof Boolean && ((Boolean) regionFactoryInitiatorEnabled).booleanValue()) ||
Boolean.parseBoolean(regionFactoryInitiatorEnabled.toString())) {
JPA_LOGGER.tracef("ServiceContributorImpl#contribute adding ORM initiator for 2lc region factory");
Expand Down

0 comments on commit ea53695

Please sign in to comment.