Can you do this with marker annotations instead?
@PersistenceUnit
@MyTestUnit
private EntityManager em;
@PersistenceUnit
@MyOtherUnit
private EntityManager em2;
@CommitAfter
@MyOtherUnit
@MyTestUnit // commit them both
void onSuccess() {...}
If you recall Tom van Dijk did a lot of work getting multiple
hibernate sessions to work. Have you looked at his additions?
http://codereview.appspot.com/2896041/
There is an email floating around with access to his git repository
and discussing issues of CommitAfter, etc.
Josh
On Wed, Feb 16, 2011 at 8:44 AM, Igor Drobiazko
<[email protected]> wrote:
> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]