Hi all,
as you probably know I'm working on the Tapestry/JPA integration. In
contrast to Tynamo's integration, Tapestry's built-in JPA support will allow
having several persistence units in an application. This way you can inject
several EntityManagers into a single page, which are connected to different
databases.
public class PersistEntity
{
@PersistenceUnit(unitName = "TestUnit")
private EntityManager em;
@PersistenceUnit(unitName = "AnotherUnit")
private EntityManager em2;
@CommitAfter
void onSuccess() {
.....
}
}
Now I have some issues to apply Tapestry's @CommitAfter semantics to JPA
resource-local transactions. With Hibernate you have a single Session, so it
is clear what to commit when @CommitAfter annotation is present: the active
transaction of the single session. With JPA you can have several
EntityManagers and so several transactions. When @CommitAfter is present,
you don't know which of the active transactions to commit.
So, the questions is what would be the best solution? Committing all the
active transactions? Maybe we could add a new attribute to @CommitAfter
annotations, which expects a list of persistence unit names to commit the
transactions of?
@CommitAfter( { "TestUnit", "AnotherUnit" } )
void onSuccess() {
.....
}
Any thoughts or ideas`?
--
Best regards,
Igor Drobiazko
http://tapestry5.de