Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transaction in session bean

 
vianyrajnish rajnish
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i want to know do i need to maintain transaction in Session Bean or Hibernate

if my project is having this architechture in order.


jsp , action servlet , request processor , action , business delegate, session bean, dao , hibernate components, then database .


1..which one is better ?
2..or it is mandratory to maintain in session bean ?

thanks,

vinay rajnish
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinay,
I would think the session bean is better because it is at a higher level. This allows all the database calls to be in the same transaction. If that is your desired behavior, the session bean transactions gives this to you easily.

The session bean is not required to have a transaction though. You can use "never" as the value.
 
vianyrajnish rajnish
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,


But hibernate too has the transaction maintainence capability ....


then which one to use....


first of all I want to know why the session beans are used ....we can directly access hibernate components from th Action , BD , DAO.

please help me ....confused

Regards,
vinay rajnish
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate supports JDBC, JTA and container-managed transactions. You need to decide which is best for your application. Coming from the EJB world, I have to admit to being biased in favour of CMT session beans.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinay,
Session beans do more than just transactions. They also handle security (among other things.) Also, using the session bean for the transaction layer makes it easier to change the back end data access technology in the future because you transaction is at the facade level. Again, this assumes you WANT a transaction at the facade level.

As Roger pointed out, it depends on your specific application. On apps I have worked on, the session bean level was almost always the right level for the transaction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic