borinquenkid commented on code in PR #15568:
URL: https://github.com/apache/grails-core/pull/15568#discussion_r3440094162


##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/CustomIsolationLevelSpec.groovy:
##########
@@ -36,7 +36,7 @@ class CustomIsolationLevelSpec extends Specification {
     @AutoCleanup @Shared HibernateDatastore hibernateDatastore = new 
HibernateDatastore(Product, Attribute)
 
 
-    @Issue('https://github.com/apache/grails-data-mapping/issues/952')
+    @Issue('https://github.com/grails/grails-data-mapping/issues/952')

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/TransactionalWithinReadOnlySpec.groovy:
##########
@@ -33,9 +33,8 @@ import spock.lang.Specification
  */
 class TransactionalWithinReadOnlySpec extends Specification {
 
-    @Shared
-    @AutoCleanup
-    HibernateDatastore datastore = new HibernateDatastore(Product, Attribute)
+    @Shared @AutoCleanup HibernateDatastore datastore = new 
HibernateDatastore(Product, Attribute)

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate7/grails-plugin/src/test/groovy/grails/orm/bootstrap/HibernateDatastoreSpringInitializerSpec.groovy:
##########
@@ -61,33 +67,32 @@ class HibernateDatastoreSpringInitializerSpec extends 
Specification{
         applicationContext.getBean("sessionFactory_moreBooks", 
SessionFactory).metamodel.entity(Author.name)
 
         and:"Each domain has the correct data source(s)"
+        HibernateDatastore hibernateDatastore = 
applicationContext.getBean(HibernateDatastore)

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate7/grails-plugin/src/test/groovy/grails/orm/bootstrap/HibernateDatastoreSpringInitializerSpec.groovy:
##########
@@ -61,33 +67,32 @@ class HibernateDatastoreSpringInitializerSpec extends 
Specification{
         applicationContext.getBean("sessionFactory_moreBooks", 
SessionFactory).metamodel.entity(Author.name)
 
         and:"Each domain has the correct data source(s)"
+        HibernateDatastore hibernateDatastore = 
applicationContext.getBean(HibernateDatastore)
         Person.withNewSession { Person.count() == 0 }
-        Person.withNewSession {  Session s ->
-            assert s.connection().metaData.getURL() == "jdbc:h2:mem:people"
-            return true
-        }
-        Book.withNewSession { Book.count() == 0 }
-        Book.withNewSession { Session s ->
-            assert s.connection().metaData.getURL() == "jdbc:h2:mem:books"
-            return true
-        }
-        Book.moreBooks.withNewSession { Session s ->
-            assert s.connection().metaData.getURL() == "jdbc:h2:mem:moreBooks"
-            return true
-        }
-        Author.withNewSession { Author.count() == 0 }
-        Author.withNewSession { Session s ->
-            assert s.connection().metaData.getURL() == "jdbc:h2:mem:people"
-            return true
-        }
-        Author.books.withNewSession { Session s ->
-            assert s.connection().metaData.getURL() == "jdbc:h2:mem:books"
-            return true
-        }
-        Author.moreBooks.withNewSession { Session s ->
-            assert s.connection().metaData.getURL() == "jdbc:h2:mem:moreBooks"
-            return true
-        }
+                hibernateDatastore.withNewSession { Session s ->
+                    assert s.doReturningWork { it.getMetaData().getURL() } == 
"jdbc:h2:mem:people"
+                    return true
+                }
+                hibernateDatastore.withNewSession("books") { Session s ->
+                    assert s.doReturningWork { it.getMetaData().getURL() } == 
"jdbc:h2:mem:books"
+                    return true
+                }
+                hibernateDatastore.withNewSession("moreBooks") { Session s ->
+                    assert s.doReturningWork { it.getMetaData().getURL() } == 
"jdbc:h2:mem:moreBooks"
+                    return true
+                }
+                hibernateDatastore.withNewSession { Session s ->
+                    assert s.doReturningWork { it.getMetaData().getURL() } == 
"jdbc:h2:mem:people"
+                    return true
+                }
+                hibernateDatastore.withNewSession("books") { Session s ->
+                    assert s.doReturningWork { it.getMetaData().getURL() } == 
"jdbc:h2:mem:books"
+                    return true
+                }
+                Author.moreBooks.withNewSession { Session s ->
+                    assert s.doReturningWork { it.getMetaData().getURL() } == 
"jdbc:h2:mem:moreBooks"
+                    return true
+                }

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-doc/src/en/guide/upgrading/upgrading80x.adoc:
##########
@@ -136,15 +136,52 @@ spring:
 ==== 5. Hibernate ORM Package Relocations
 
 Spring Framework 7 removed the `org.springframework.orm.hibernate5` package 
entirely.
-Grails 8 vendors these classes from Spring Framework 6.2.x into a new module 
(`grails-data-hibernate5-spring-orm`) under the package 
`org.grails.orm.hibernate.support.hibernate5`.
+Grails 8 vendors these classes from Spring Framework 6.2.x into two new 
modules — one per supported Hibernate version — so that both Hibernate 5 and 
Hibernate 7 users have a drop-in replacement.

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-doc/src/en/guide/upgrading/upgrading80x.adoc:
##########
@@ -964,3 +1003,182 @@ Previously, rendering an enum value would produce a JSON 
string with the type an
 
 Rendering an enum value as JSON will now instead throw a `ConverterException`.
 See https://github.com/apache/grails-core/pull/15212[PR 15212] for more 
details on this change.
+
+[[_hibernate_5_to_hibernate_7_migration]]
+==== 23. Hibernate 5 to Hibernate 7 Migration
+
+Grails 8 supports both Hibernate 5 (the default) and Hibernate 7.
+If you are upgrading from Grails 7 and also want to migrate from Hibernate 5 
to Hibernate 7, apply the `grails-hibernate7-bom` and the Hibernate 7 plugin in 
addition to the standard Grails 8 upgrade steps.
+
+[source,groovy]
+.build.gradle — switch to Hibernate 7
+----
+dependencies {
+    implementation 
enforcedPlatform("org.apache.grails:grails-hibernate7-bom:$grailsVersion")
+    implementation 'org.apache.grails:grails-hibernate7'
+}
+----
+
+The following sections cover every breaking change introduced between 
Hibernate ORM 5.6.x (used by Grails 7) and Hibernate ORM 7.0.x, and what you 
need to do in your Grails application.
+
+===== 23.1 Hibernate Session API Removals
+
+Hibernate 7 removed long-deprecated Hibernate-specific session methods in 
favour of the standard JPA equivalents.
+GORM's dynamic methods (`save()`, `delete()`, `get()`, `load()`, `merge()`, 
etc.) are **not** affected — these go through GORM's own persistence API and 
have been updated internally.
+
+You are only affected if your code calls the Hibernate `Session` or 
`StatelessSession` directly (e.g. inside a `withSession` or 
`withStatelessSession` block).
+
+[cols="1,1", options="header"]
+|===
+| Removed (Hibernate 5/6)
+| Replacement (Hibernate 7 / JPA)
+
+| `session.save(entity)`
+| `session.persist(entity)`
+
+| `session.update(entity)`
+| `session.merge(entity)`
+
+| `session.saveOrUpdate(entity)`
+| `session.persist(entity)` (new) or `session.merge(entity)` (detached)
+
+| `session.delete(entity)`
+| `session.remove(entity)`
+
+| `session.load(Class, id)`
+| `session.getReference(Class, id)`
+
+| `session.get(Class, id)`
+| `session.find(Class, id)`
+|===
+
+===== 23.2 Removed Hibernate Annotations
+
+The following Hibernate-specific annotations were removed in Hibernate 7.
+Where a replacement exists, migrate before upgrading.
+
+[cols="1,2", options="header"]
+|===
+| Removed annotation
+| Action required
+
+| `@org.hibernate.annotations.Where`
+| Replace with `@org.hibernate.annotations.SQLRestriction`
+
+| `@org.hibernate.annotations.WhereJoinTable`
+| Replace with `@org.hibernate.annotations.SQLJoinTableRestriction`
+
+| `@org.hibernate.annotations.Proxy`
+| Remove — proxy configuration is no longer supported
+
+| `@org.hibernate.annotations.LazyCollection`
+| Remove and use `@ManyToMany(fetch = FetchType.LAZY)` or `EAGER` directly
+
+| `@org.hibernate.annotations.Persister`
+| Remove — custom persisters are no longer supported
+
+| `@org.hibernate.annotations.SelectBeforeUpdate`
+| Remove — behaviour is now configurable via `@DynamicUpdate`
+
+| `@org.hibernate.annotations.Loader`
+| Remove — custom SQL loaders are no longer supported; use `@SQLSelect` on the 
entity itself
+|===
+
+NOTE: Grails domain classes that use the `mapping { }` DSL are not affected by 
annotation removals.
+These annotations only apply if you are using Hibernate annotations directly 
on Java or Groovy classes.
+
+===== 23.3 CascadeType.SAVE_UPDATE Removed
+
+`CascadeType.SAVE_UPDATE` (a Hibernate-specific cascade type) was removed in 
Hibernate 7.
+Persisting a transient entity that has detached associations now throws 
`EntityExistsException` instead of silently merging.
+
+If your domain mapping or annotated classes used `cascade = 
CascadeType.SAVE_UPDATE`, replace it with `cascade = CascadeType.ALL` or 
`cascade = [CascadeType.PERSIST, CascadeType.MERGE]` as appropriate.
+
+Also note that automatic `cascade=PERSIST` on `@Id` and `@MapsId` associations 
was removed.

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/BackticksRemover.java:
##########
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.orm.hibernate.cfg.domainbinding.util;
+
+import java.util.Optional;
+import java.util.function.Function;
+
+/** The backticks remover class. */

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java:
##########
@@ -499,7 +499,8 @@ protected void bindCollectionSecondPass(ToMany property, 
InFlightMetadataCollect
             }
         } else {
             if (hasJoinKeyMapping(propConfig)) {
-                bindSimpleValue("long", key, false, 
propConfig.getJoinTable().getKey().getName(), mappings);
+                java.util.List<ColumnConfig> keys = 
propConfig.getJoinTable().getKeys();

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java:
##########
@@ -499,7 +499,8 @@ protected void bindCollectionSecondPass(ToMany property, 
InFlightMetadataCollect
             }
         } else {
             if (hasJoinKeyMapping(propConfig)) {
-                bindSimpleValue("long", key, false, 
propConfig.getJoinTable().getKey().getName(), mappings);
+                java.util.List<ColumnConfig> keys = 
propConfig.getJoinTable().getKeys();
+                bindSimpleValue("long", key, false, keys.get(0).getName(), 
mappings);

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



##########
grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java:
##########
@@ -2392,7 +2393,9 @@ protected void bindManyToOne(Association property, 
ManyToOne manyToOne,
                     final ColumnConfig columnConfig = new ColumnConfig();
                     
columnConfig.setName(namingStrategy.propertyToColumnName(property.getName()) +
                             UNDERSCORE + FOREIGN_KEY_SUFFIX);
-                    jt.setKey(columnConfig);
+                    java.util.List<ColumnConfig> keys = new 
java.util.ArrayList<>();

Review Comment:
   Reverted — this file is unchanged from `8.0.x` in the current revision.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to