-
Notifications
You must be signed in to change notification settings - Fork 60
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
add methods for managing Session/Transaction lifecycle to SessionFactory #410
Comments
I presume the alternative of using try-with-resources blocks is not workable? Seems it could be done for EntityManager but problematic to get a transaction.close() in place? |
@rbygrave I don't think we would have a good way to detect that an exception had been thrown from code inside |
Folks, any feedback on #414? One issue here is whether we need two flavors of I think we do, but I don't know what to call them. |
@hantsy @Tomas-Kraus @lukasj and everyone else:
So according to 2, you would write: entityManagerFactory.execute(TxType.REQUIRED, entityManager -> {
entityManager.persist(book);
}); which is obviously quite a lot harder to type than: entityManagerFactory.executeInTransaction(entityManager -> {
entityManager.persist(book);
}); But it's not actually that much worse to look at, and it's quite a lot more flexible. Another argument agains 2 is that the way
We could of course define our own |
For now, let's go without direct dependency on JTA API which would bring in CDI API (transitively) |
See #410 Co-authored-by: Lukas Jungmann <[email protected]>
The transaction management idiom in JPA is not so trivial:
I think we should add a
withTransaction()
method toEntityManagerFactory
declared as follows:The
work
would be performed within the scope of a resource-local transaction.The text was updated successfully, but these errors were encountered: