Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why Entity Beans Only?  RSS feed

 
Jack Nicholson
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have basic Question About the Selecting Correct EJB.
As We Can Write the SessionBean which can persist the data, Why Entity Beans are preferred?
SessionBeans Can do this by implementing SessionSynchronization interface.
What is the extra which we get it from entity bean?
Thanx in advance.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entity beans are basically a way to model data as objects, whereas session beans are essentially wrappers for behaviour.
While you can write persistence (typically JDBC) code inside your session beans, the benefit of using entity beans (particularly CMP) is that they take care of (1) the object to relational mapping and (2) the CRUD operations. In other words, they provide an easy programming model for access to persistent data.
Of course the drawback is that they are complex and often overkill for smaller projects.
Simon
 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Added to what simon has mentioned,session synchronisation doesn't help you in persisting the data, but it helps you to know when your bean has entered the transaction and when it has completed the transaction by using call back methods.
Harish
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!