Play 2.2.2 @Transactional eBean does not roll back transaction in Exception throw

It seems that when using Play Framework 2.2.2 with eBean, ORM @ play.db.ebean.Transactional does not cancel the transaction when an exception is thrown.

Do any of you know something about the problem and how can it be solved?

I saw that eBean has an ERROR on this issue in its avaje-ebeanorm-agent 3.2.2 .: https://github.com/ebean-orm/avaje-ebeanorm/pull/44 , which is fixed in version avaje-ebeanorm 3.2 .3 Also playing 2.2.2 seems to use avaje-ebeanorm-agent 3.2.2, and when I change it to a higher version in Built.scala (3.2.5) there were some crashes when using JPA annotations (for example, orphanRemoval is not recognized)

PS There is a similar discussion with game 2.1.1, play 2.1.1: it is impossible to complete a transaction with a return to ebean orm , but there is no clear resolution to the problem of using @Transactional in action.

+4
source share
1 answer

I had similar problems, however I only tested the game version 2.3.7:

I noticed that there are two different libraries containing the Transactional annotation: @com.avaje.ebean.annotation.Transactionaland @play.db.ebean.Transactional.

Apparently, each of them works only in certain types of classes, and when used incorrectly, rollback is not performed. This is what I learned while testing:

  • @com.avaje.ebean.annotation.Transactional: , , .. @javax.persistence.Entity. , , ebean, ,
  • ebean , . try/finally. .
  • @play.db.ebean.Transactional: , .. play.mvc.Controller. , , .
+3

Source: https://habr.com/ru/post/1534520/


All Articles