I'm trying to do 2 deletes, one managed by jpa and other by jdbc. The jdbc delete is made by jbossesb api, I don't have any control.
I can delete when I do 2 methods for each delete using @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) . But I need the both delete in same transaction, because or delete both or any.
Follow my situation: jboss do an insert on table(jdbc) A and the id generated is used to insert on table(jpa) B. These tables don't have relationship, the id from table A is just a field on table B, no pk or fk.
Table A is created by jboss and has own datasource, table B is created by me and have other datasource, table B is a java @Entity.
The transactions are control by container
How could I do the both delete in same transaction ???
everson santos wrote:at moment i can't use xa datasource. But if it is only solution i'll try do that
You need to use an XA datasource for two different connections to synchronize their commits. If the two tables accessed by the same user id, you could use the same connection. You have to be careful on who commits the transaction though.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How to do transaction with EJB/JPA and JDBC