Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomikos, JaVers, and Hibernate #192

Open
ghost opened this issue Oct 11, 2023 · 0 comments
Open

Atomikos, JaVers, and Hibernate #192

ghost opened this issue Oct 11, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 11, 2023

Hi all

I am having an issue getting the latest versions of Atomikos, JaVers, and Hibernate to work together on a Spring Boot 3 project. After some debugging, I have managed to narrow the issue down to the fact that JaVers is receiving an already closed connection from the entity manager, which is then throwing a SQL exception. The code that JaVers uses to get a connection is as follows:

public Connection getConnection() {
  Session session = (Session)this.entityManager.unwrap(Session.class);
  GetConnectionWork connectionWork = new GetConnectionWork();
  session.doWork(connectionWork);
  return connectionWork.theConnection;
}

After which it performs its inserts into the audit tables using that connection. This all works out of the box using native JPA and Hibernate, however as soon as I add in the Atomikos dependency to make the application transactional, the connection being returned is already closed.

Looking at the Hibernate documentation and suggestions, it is my understanding that the recommended way to perform work on a session is to pass it in to the doWork() and doReturningWork() methods rather than using the connection directly. Unfortunately, this is not the way that JaVers works.

So my question is, if I create a custom ConnectionProvider, is there any way I can get an open connection from the entity manager's session while using Atomikos/JTA?

Any help or suggestions would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants