0

I have a transaction closing syntax working for a long time in a webapp. It's running hibernate 4.3.10.Final:

if(t!=null && !t.wasCommitted()) t.rollback();
if(s!=null) s.close();
// t is a org.hibernate.Transaction, s is a org.hibernate.Session

Now this webapp will run in and updated environment, with hibernate 5.1.10.Final. This current code gives me an java.lang.NoSuchMethodError: org.hibernate.Transaction.wasCommitted()Z exception.

Is it possible to update this code and make it runnable in both hibernate versions? If not, how should I change it so it works with hibernate 5?

Bruno Lamps
  • 544
  • 6
  • 27
  • 1
    related: https://stackoverflow.com/q/42866985/217324 – Nathan Hughes Aug 28 '19 at 14:26
  • Thanks @NathanHughes ! Unfortunatelly I tried to code something based in `org.hibernate.Version.getVersionString()`, but the version of org.hibernate.Session I'm currently running doesn't have the method `session.getTransaction().getStatus()`. I'll find out if I can have 2 different hibernate dependencies in my project. – Bruno Lamps Aug 28 '19 at 15:04

1 Answers1

0

It is possible to check your hibernate version using org.hibernate.Version.getVersionString(), but it's far from trivial (and not recommended) to have 2 different versions of hibernate libs in your project.

I'm branching a new version of the webapp and updating hibernate in this version.

Bruno Lamps
  • 544
  • 6
  • 27