Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Transactions  RSS feed

 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a scenario where I have two business entities. Say B1 and B2. I have writen Stateless session beans for B1 and B2. I have B1DB, B2DB which my session beans would talk to, inorder to make any database queries. I haven't decided if I have go with entity beans for B1DB and B2DB.

Now, on few scenarios when I update B1 data, I have to update B2 data. To acheive this,

1. I can call B2 update method from B1 update method. In this case how can I control transaction. I mean if B2 update is unsuccessfull, I have to roll back B1 update and vice versa. If I specify trasaction=true for business beans in the deployment descriptor would take care this situation?

2. Write a stored procedure that would update both the tables and commit whole transaction on sucess else roll back.
Is this the correct approach?.

Please suggest me.
Saritha
 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please suggest me on this.
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi saritha,
You can call B2 update method from B1 and can specify that both the updates should be in same transaction. Which app server you are using. You need to specify the transaction attributes.

Regards,
Sawan
 
Shailesh Chandra
Ranch Hand
Posts: 1084
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your Session Bean B1 & B2 are having somw comman functionality .......

then what about if you extend B2 with B1.........
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!