Ticket 1.2: Update persistence.xml files for Hibernate 6 compatibility#1
Conversation
- Update XML namespace from javax to Jakarta EE (https://jakarta.ee/xml/ns/persistence) - Update persistence version from 2.0 to 3.0 - Update schema location to persistence_3_0.xsd - Remove hibernate.id.new_generator_mappings (always true in Hibernate 6) - Change hibernate.javax.cache.provider to hibernate.jakarta.cache.provider - Remove explicit hibernate.dialect (Hibernate 6 auto-detects dialect) - Update hibernate.ejb.session_factory_observer to hibernate.session_factory_observer - Remove hibernate.enable_lazy_load_no_trans (removed in Hibernate 6) Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| <property name="hibernate.transaction.flush_before_completion" value="false"/> | ||
| <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jcache.JCacheRegionFactory"/> | ||
| <property name="hibernate.javax.cache.provider" value="org.ehcache.jsr107.EhcacheCachingProvider"/> | ||
| <property name="hibernate.jakarta.cache.provider" value="org.ehcache.jsr107.EhcacheCachingProvider"/> |
There was a problem hiding this comment.
🔴 Incomplete javax→jakarta migration: JCachePersistenceUnitPostProcessor still sets old hibernate.javax.cache.* property names
The persistence XML files were updated to use the new hibernate.jakarta.cache.provider property name (JPA 3.0 / Hibernate 6), but JCachePersistenceUnitPostProcessor.java:71 still sets hibernate.javax.cache.uri and JCachePersistenceUnitPostProcessor.java:78 still sets hibernate.javax.cache.provider programmatically on the persistence unit. In Hibernate 6 (required for JPA 3.0), these old property names are not recognized, so the programmatic JCache configuration (cache URI and cache provider override) will silently have no effect. The XML's hibernate.jakarta.cache.provider value will also coexist with a stale hibernate.javax.cache.provider key set by the post-processor, causing confusion.
Prompt for agents
The persistence XML files were updated from hibernate.javax.cache.provider to hibernate.jakarta.cache.provider, but the Java code in JCachePersistenceUnitPostProcessor (common/src/main/java/org/broadleafcommerce/common/extensibility/jpa/JCachePersistenceUnitPostProcessor.java) was not updated to match. Specifically:
1. Line 71: properties.setProperty("hibernate.javax.cache.uri", ...) should use "hibernate.jakarta.cache.uri"
2. Line 78: properties.setProperty("hibernate.javax.cache.provider", cacheProvider) should use "hibernate.jakarta.cache.provider"
3. Line 49: The @Value annotation reads from the Spring property hibernate.javax.cache.provider — consider updating the Spring property name too for consistency, or add a note that this is a Spring-level property name.
Additionally, DefaultJCacheUriProvider.java (common/src/main/java/org/broadleafcommerce/common/extensibility/cache/DefaultJCacheUriProvider.java) has:
1. Line 37: @Value("${hibernate.javax.cache.uri:#{null}}") — same Spring-level naming concern
2. Line 40: @Value("${hibernate.javax.cache.uri.relative:true}") — same concern
3. Lines 54 and 58: Log/error messages referencing the old property names
All hibernate.javax.cache.* property keys set on the Hibernate persistence unit must be updated to hibernate.jakarta.cache.* to be recognized by Hibernate 6.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Good catch — confirmed that JCachePersistenceUnitPostProcessor.java (lines 71, 78) and DefaultJCacheUriProvider.java (lines 37, 40, 54, 58) still reference the old hibernate.javax.cache.* property names.
However, this PR is scoped to XML configuration files only per the ticket constraints ("Do NOT change Java source code — only XML configuration files"). The Java-side javax→jakarta migration for these cache properties should be addressed in a separate ticket covering the Java source code migration.
I've verified the specific lines that will need updating:
JCachePersistenceUnitPostProcessor.java:49—@Value("${hibernate.javax.cache.provider:#{null}}")JCachePersistenceUnitPostProcessor.java:71—properties.setProperty("hibernate.javax.cache.uri", ...)JCachePersistenceUnitPostProcessor.java:78—properties.setProperty("hibernate.javax.cache.provider", ...)DefaultJCacheUriProvider.java:37—@Value("${hibernate.javax.cache.uri:#{null}}")DefaultJCacheUriProvider.java:40—@Value("${hibernate.javax.cache.uri.relative:true}")DefaultJCacheUriProvider.java:54,58— log/error messages with old property names
…s args, add @TestMethodOrder/@order - Issue #1: Remove unused Method parameter from CustomerPhoneControllerTest.setupCustomerId() to prevent JUnit 5 ParameterResolutionException - Issue #2: Swap assertEquals argument order from TestNG convention (actual, expected) to JUnit 5 convention (expected, actual) in RollbackTest, SystemPropertiesTest, WorkflowTest - Issue #3: Add @TestMethodOrder(MethodOrderer.OrderAnnotation.class) and @order(N) annotations to 21 test classes with execution order dependencies to preserve test method ordering - Use fully qualified @org.junit.jupiter.api.Order where it conflicts with domain Order class Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
Brief Overview
Migrates all 7 persistence XML files from JPA 2.0 / Hibernate 5.x configuration to Jakarta Persistence 3.0 / Hibernate 6 as part of the Hibernate 6 upgrade effort.
Changes
Applied across all 7 files:
http://java.sun.com/xml/ns/persistence→https://jakarta.ee/xml/ns/persistence2.0→3.0persistence_3_0.xsdhibernate.dialect(Hibernate 6 auto-detects from JDBC URL)hibernate.id.new_generator_mappings(always-on in Hibernate 6)Property renames:
hibernate.javax.cache.provider→hibernate.jakarta.cache.provider(inpersistence-common.xml,persistence-cms.xml)hibernate.ejb.session_factory_observer→hibernate.session_factory_observer(inpersistence-open-admin.xml)Removed deprecated properties:
hibernate.enable_lazy_load_no_transremoved from all 3 persistence units inpersistence-test.xml(property no longer exists in Hibernate 6)Files Changed
common/src/main/resources/META-INF/persistence-common.xmlcore/broadleaf-profile/src/main/resources/META-INF/persistence-profile.xmlcore/broadleaf-framework/src/main/resources/META-INF/persistence-framework.xmladmin/broadleaf-open-admin-platform/src/main/resources/META-INF/persistence-open-admin.xmladmin/broadleaf-contentmanagement-module/src/main/resources/META-INF/persistence-cms.xmlcommon/src/test/resources/META-INF/persistence-common-test.xmlintegration/src/test/resources/META-INF/persistence-test.xmlNo Java source code was modified.
Labels
Human Review Checklist
hibernate.session_factory_observerrename (persistence-open-admin.xml): Verify thatSessionFactoryChangeListenerimplements the Hibernate 6SessionFactoryObserverinterface correctly — the property key changed fromhibernate.ejb.session_factory_observer.HSQLDialecthardcoded; removal relies on Hibernate 6 inferring the dialect from the JDBC URL. Confirm HSQLDB test data sources provide a recognizable URL.hibernate.enable_lazy_load_no_transremoval (persistence-test.xml): This property no longer exists in Hibernate 6. Verify integration tests don't depend on lazy-loading outside a transaction context.hibernate.cache.region.factory_classstill referencesorg.hibernate.cache.jcache.JCacheRegionFactory— consider whether the Hibernate 6 class path (org.hibernate.cache.jcache.internal.JCacheRegionFactory) is required or if the old name still resolves.Link to Devin session: https://app.devin.ai/sessions/c7dcc419268d4992b5a358fbbaed4507
Requested by: @Colhodm