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


##########
grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/transaction/HibernateJtaTransactionManagerAdapter.java:
##########
@@ -1,235 +0,0 @@
-/*
- *  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.transaction;
-
-import javax.transaction.xa.XAResource;
-
-import jakarta.transaction.RollbackException;
-import jakarta.transaction.Status;
-import jakarta.transaction.Synchronization;
-import jakarta.transaction.SystemException;
-import jakarta.transaction.Transaction;
-import jakarta.transaction.TransactionManager;
-
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-import org.springframework.transaction.support.TransactionSynchronization;
-import 
org.springframework.transaction.support.TransactionSynchronizationManager;
-
-/**
- * Adapter for adding transaction controlling hooks for supporting
- * Hibernate's org.hibernate.engine.transaction.Isolater class's interaction 
with transactions
- *
- * This is required when there is no real JTA transaction manager in use and 
Spring's
- * {@link org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy} 
is used.
- *
- * Without this solution, using Hibernate's TableGenerator identity strategies 
will fail to support transactions.
- * The id generator will commit the current transaction and break 
transactional behaviour.
- *
- * The javadoc of Hibernate's {@code TableHiLoGenerator} states this. However 
this isn't mentioned in the javadocs of other TableGenerators.
- *
- * @author Lari Hotari
- */
-public class HibernateJtaTransactionManagerAdapter implements 
TransactionManager {

Review Comment:
    What it did: HibernateJtaTransactionManagerAdapter was a workaround adapter 
introduced to fix GRAILS-10945 / GRAILS-11133 
(https://github.com/grails/grails-data-mapping/commit/3aa052ee6e). The problem 
it
     solved: Hibernate's TableGenerator identity strategy internally calls 
Hibernate's Isolater class, which expects a real JTA TransactionManager. When 
only Spring's TransactionAwareDataSourceProxy is in use (no
     real JTA), TableGenerator would commit the active transaction, breaking 
transactional behaviour. The adapter made Spring's PlatformTransactionManager 
look like a JTA TransactionManager to satisfy that
     contract.
   
     Was it used? No — there are zero references to the class anywhere in 
grails-data-hibernate5/. A grep -r across the whole module finds nothing. It 
was never wired into any Spring config, never instantiated in
     HibernateDatastoreSpringInitializer, never referenced from any other 
class. The deletion commit message "removed unused code" is accurate.
   
     Why it became dead code: The underlying Hibernate TableGenerator / 
Isolater interaction this worked around changed significantly in Hibernate 5.x 
(table-based ID generators were overhauled in 5.x, and
     SequenceStyleGenerator became the recommended default). There was simply 
no live code path that ever instantiated or injected the adapter.
   
     Bottom line: The deletion was correct — it was an orphaned workaround for 
a problem that no longer manifested. You can reply to that PR thread confirming 
it was validly removed as dead code with no callers in
     the module.
   
   



-- 
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