Reputation: 21
I am facing a problem using programmatic or/and declarative transaction management using spring in a project that I've been working.
Because the Entities "area created at runtime" based in a SQL-Schema (bytebuddy and jdbc) that obligated me to extends the DefaultPersistenceUnitManager class and the LocalContainerEntityManagerFactoryBean class from spring framework.
When i started the unit testing beginning with EntityManager (PersistenceContext) and transaction demarcation using Hibernate the tests running well.
When I declared a PlatformTransactionManager(JpaTransactionManager) to delegate to Spring to manage the transaction for save/flush/delete operations the test fires the exception bellow.
Since i have to manipulate the classloader using bytebuddy, i was wondering the the TransactionManager(JpaTransactionManager) depends on some particular feature of the LocalContainerEntityManagerFactoryBean like the VendorAdapter (HibernateVendorAdapter) or
SpringHibernateJpaPersistenceProvider that was also modified in the project.
For Example: using declarative transaction management , the TransactionManager attribute is null in the TransactionInterceptor and in programmatic transaction management it fires the exception bellow.
the part of interest of the code that extends Spring Classes is in the link https://github.com/JoseCanova/metaclass-dataservice/tree/main/src/main/java/org/nanotek/config
Regards,
Any clue about Spring TransactionManagement internals might Help.
2025-02-20T14:45:56.637-03:00 DEBUG 45462 --- [ main] o.h.e.t.internal.TransactionImpl : begin 2025-02-20T14:45:56.639-03:00 DEBUG 45462 --- [ main] org.postgresql.jdbc.PgConnection : setAutoCommit = false 2025-02-20T14:45:57.783-03:00 DEBUG 45462 --- [ main] org.hibernate.orm.sql.exec : Skipping reading Query result cache data: cache-enabled = false, cache-mode = IGNORE 2025-02-20T14:45:57.842-03:00 DEBUG 45462 --- [ main] org.hibernate.SQL : select sdt1_0.simple_key,sdt1_0.simple_date,sdt1_0.simple_time,sdt1_0.simple_times_zone,sdt1_0.simple_timestamp,sdt1_0.simple_timestamp_zone from simple_date_table sdt1_0 where sdt1_0.simple_key=? 2025-02-20T14:45:57.948-03:00 DEBUG 45462 --- [ main] org.hibernate.orm.results : Initializer list:
org.nanotek.data.SimpleDateTable -> EntityJoinedFetchInitializer(org.nanotek.data.SimpleDateTable)@75465588 (SingleTableEntityPersister(org.nanotek.data.SimpleDateTable))2025-02-20T14:45:58.160-03:00 DEBUG 45462 --- [ main] cResourceLocalTransactionCoordinatorImpl : JDBC transaction marked for rollback-only (exception provided for stack trace)
java.lang.Exception: exception just for purpose of providing stack trace at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.markRollbackOnly(JdbcResourceLocalTransactionCoordinatorImpl.java:309) ~[hibernate-core-6.6.5.Final.jar:6.6.5.Final] at org.hibernate.engine.transaction.internal.TransactionImpl.markRollbackOnly(TransactionImpl.java:203) ~[hibernate-core-6.6.5.Final.jar:6.6.5.Final] at org.hibernate.engine.transaction.internal.TransactionImpl.setRollbackOnly(TransactionImpl.java:224) ~[hibernate-core-6.6.5.Final.jar:6.6.5.Final] at org.springframework.orm.jpa.JpaTransactionManager$JpaTransactionObject.setRollbackOnly(JpaTransactionManager.java:716) ~[spring-orm-6.2.2.jar:6.2.2] at org.springframework.orm.jpa.JpaTransactionManager.doSetRollbackOnly(JpaTransactionManager.java:615) ~[spring-orm-6.2.2.jar:6.2.2] at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:906) ~[spring-tx-6.2.2.jar:6.2.2]
Upvotes: 0
Views: 21