I'm migrating from hibernate 4.2.17 to 5.0.7 which works fine so far, but it seems that the method isActive
is deprecated. I just can't use it anymore.
Here's my code:
public void starteTransaktion() {
try {
getMySession();
if(!hibernateSession.getTransaction().isActive()) {
hibernateSession.beginTransaction();
}
} catch (HibernateException e) {
}
}
I substituted all other methods, but I can't quite find a replacement for this...
Error message: The method isActive()
is undefined for the type Transaction
The @Transactional annotation is the metadata that specifies the semantics of the transactions on a method. We have two ways to rollback a transaction: declarative and programmatic. In the declarative approach, we annotate the methods with the @Transactional annotation.
Therefore, you can run multiple transactions on the same Hibernate Session, but there's a catch. Once an exception is thrown you can no longer reuse that Session. My advice is to divide-and-conquer. Just split all items, construct a Command object for each of those and send them to an ExecutorService#invokeAll .
As per 5.0 Javadoc:
hibernateSession.getTransaction().getStatus() != TransactionStatus.ACTIVE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With