JEE-Transaction- vs. JPA Entity Management

57 Views Asked by At

We migrated a websphere app into a cloud environment running with spring boot. It went pretty fine!

In a second step we migrated messaging from ibm-mq to kafka. With this migration we don't need the two-phase-commit because both go, db and messaging, with one commit to the db.

Now we should upgrade to spring boot 3 and tomcat 10 with the jakarta-namespace. There we face the problem with the orm, eclipselink and the definition of the bitronix transactionmanager:

final SessionManager manager = org.eclipse.persistence.sessions.factories.SessionManager.getManager();
Server server = (Server) manager.getSession(xmlLoader, ECLIPSELINK_SESSION_CONFIG, classLoader, false, false);
// Set the external transaction controller and use JTA transacion manager
server.setExternalTransactionController(eclipselinkTransactionController);

Eclipselink 3.0 supports the jakarta namespace but bitronix doesn't.

I see two solutions: (1.) finde a jee transaction-manager which supports jakarta (even if we don't need two-phase-commit anymore) or (2.) we use the jpa entity-manager from spring boot.

I tried (2.) but in the code it gets a session and a unit-of-work from eclipse-link but the unit-of-work is null.

EclipseLinkSessionService service = EclipseLinkSessionServiceFactory.createService();
UnitOfWork uow = service.getUnitOfWork();
uow.registerObject(myEntity);

Any suggestions how to continue?

1

There are 1 best solutions below

0
On

If your transaction manager supports JTA and you are using JTA APIs Migrating to Jakarta namespace will be relatively easy job since most Transaction managers do the same thing and API doesn't change but if isn't you may have to do some changes and tests.

I have googled and found out bitronix is a JTA implementation so you need to just change dependency to jakarta transaction manager.

Like this one: https://mvnrepository.com/artifact/org.jboss.narayana.jta/narayana-jta/7.0.1.Final

Or this one: https://mvnrepository.com/artifact/io.openliberty.features/io.openliberty.jta-2.0

or this one: https://mvnrepository.com/artifact/org.glassfish.main.transaction/jta

https://mvnrepository.com/artifact/org.nuxeo.runtime/nuxeo-runtime-jtajca

https://mvnrepository.com/artifact/com.atomikos/transactions-jta

https://mvnrepository.com/artifact/fish.payara.server.internal.transaction/jta If your JTA implementation isn't in the list comment below.