From 54db32a4e144b456f93949a46017cde1157dd916 Mon Sep 17 00:00:00 2001 From: James Fredley Date: Wed, 19 Feb 2025 21:44:47 -0500 Subject: [PATCH 1/2] Update example projects to set hibernate-ehcache dependency While excluding hibernate-core (javax) and including jboss-transaction-api --- examples/grails3-hibernate5-mongodb/build.gradle | 8 +++++++- examples/gson-templates/build.gradle | 8 ++++++++ examples/gson-templates/grails-app/conf/application.yml | 2 +- gradle.properties | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/grails3-hibernate5-mongodb/build.gradle b/examples/grails3-hibernate5-mongodb/build.gradle index 4088f770..c55092d4 100644 --- a/examples/grails3-hibernate5-mongodb/build.gradle +++ b/examples/grails3-hibernate5-mongodb/build.gradle @@ -22,7 +22,13 @@ dependencies { runtimeOnly 'org.grails.plugins:scaffolding' runtimeOnly 'org.grails:grails-plugin-i18n' runtimeOnly 'org.grails:grails-plugin-url-mappings' - runtimeOnly 'org.hibernate:hibernate-ehcache' + runtimeOnly "org.hibernate:hibernate-ehcache:$hibernateVersion", { + // exclude javax variant of hibernate-core + exclude group: "org.hibernate", module: "hibernate-core" + } + runtimeOnly "org.jboss.spec.javax.transaction:jboss-transaction-api_1.3_spec:$jbossTransactionApiVersion", { + // required for hibernate-ehcache to work with javax variant of hibernate-core excluded + } runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure' runtimeOnly 'org.springframework.boot:spring-boot-starter-logging' runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat' diff --git a/examples/gson-templates/build.gradle b/examples/gson-templates/build.gradle index 6bc025a9..a4c94442 100644 --- a/examples/gson-templates/build.gradle +++ b/examples/gson-templates/build.gradle @@ -24,6 +24,14 @@ dependencies { runtimeOnly project(':views-json-templates') runtimeOnly 'com.bertramlabs.plugins:asset-pipeline-grails' + runtimeOnly "org.hibernate:hibernate-ehcache:$hibernateVersion", { + // exclude javax variant of hibernate-core + exclude group: "org.hibernate", module: "hibernate-core" + } + runtimeOnly "org.jboss.spec.javax.transaction:jboss-transaction-api_1.3_spec:$jbossTransactionApiVersion", { + // required for hibernate-ehcache to work with javax variant of hibernate-core excluded + } + integrationTestImplementation 'org.grails:grails-testing-support' } diff --git a/examples/gson-templates/grails-app/conf/application.yml b/examples/gson-templates/grails-app/conf/application.yml index d6167b9b..41dceb75 100644 --- a/examples/gson-templates/grails-app/conf/application.yml +++ b/examples/gson-templates/grails-app/conf/application.yml @@ -74,7 +74,7 @@ hibernate: queries: false use_second_level_cache: false use_query_cache: false - #region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' + region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' endpoints: jmx: diff --git a/gradle.properties b/gradle.properties index 03af53d8..a2a79f63 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,8 @@ testcontainersMongodbVersion=1.20.1 # for example apps only grailsSpringSecurityCoreVersion=7.0.0-SNAPSHOT grailsSpringSecurityRestVersion=6.0.0-SNAPSHOT +hibernateVersion=5.6.15.Final +jbossTransactionApiVersion=2.0.0.Final # This prevents the Grails Gradle Plugin from unnecessarily excluding slf4j-simple in the generated POMs # https://github.com/grails/grails-gradle-plugin/issues/222 From 705a7224de6d3edaf2b2c08d63d4f6943718bc85 Mon Sep 17 00:00:00 2001 From: James Fredley Date: Wed, 19 Feb 2025 22:30:43 -0500 Subject: [PATCH 2/2] Remove ehcache configuration from gson-templates since it does not use hibernate --- examples/gson-templates/build.gradle | 8 -------- examples/gson-templates/grails-app/conf/application.yml | 7 ------- 2 files changed, 15 deletions(-) diff --git a/examples/gson-templates/build.gradle b/examples/gson-templates/build.gradle index a4c94442..6bc025a9 100644 --- a/examples/gson-templates/build.gradle +++ b/examples/gson-templates/build.gradle @@ -24,14 +24,6 @@ dependencies { runtimeOnly project(':views-json-templates') runtimeOnly 'com.bertramlabs.plugins:asset-pipeline-grails' - runtimeOnly "org.hibernate:hibernate-ehcache:$hibernateVersion", { - // exclude javax variant of hibernate-core - exclude group: "org.hibernate", module: "hibernate-core" - } - runtimeOnly "org.jboss.spec.javax.transaction:jboss-transaction-api_1.3_spec:$jbossTransactionApiVersion", { - // required for hibernate-ehcache to work with javax variant of hibernate-core excluded - } - integrationTestImplementation 'org.grails:grails-testing-support' } diff --git a/examples/gson-templates/grails-app/conf/application.yml b/examples/gson-templates/grails-app/conf/application.yml index 41dceb75..197837d4 100644 --- a/examples/gson-templates/grails-app/conf/application.yml +++ b/examples/gson-templates/grails-app/conf/application.yml @@ -69,13 +69,6 @@ grails: taglib: none staticparts: none --- -hibernate: - cache: - queries: false - use_second_level_cache: false - use_query_cache: false - region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' - endpoints: jmx: unique-names: true