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

newbie question : about EJB and Database

 
Neha Dhaka
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie to EJB ,just have one question in mind,instead of writing session and entity bean and mapping them to tables in distributed application to get database access ,why don't we make the direct calls to the database .
As we generally make calls in web application using DAO, which is also multi tier and distributed application .
whether it due to extra level security which ejb provoides we use ejb,or it is due to Object Relational mapping due to which we
use ejb.
I would be thankful if anybody can clarify.

Raja
 
Neha Dhaka
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,Please reply!!

Raja
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raja Tonk:
I am a newbie to EJB ,just have one question in mind,instead of writing session and entity bean and mapping them to tables in distributed application to get database access ,why don't we make the direct calls to the database .
As we generally make calls in web application using DAO, which is also multi tier and distributed application .
whether it due to extra level security which ejb provoides we use ejb,or it is due to Object Relational mapping due to which we
use ejb.
I would be thankful if anybody can clarify.

Raja

You don't map session beans to tables in a relational database. Entity beans are the Object Relational Mapping component of J2EE. Using EJBs allows access to a range of container provided services (transaction management, security etc.) In my opinion, there is no good reason to use Entity Beans in favour of straight JDBC (via DAOs), however there is a case to use a better ORM technology (such as Hibernate). The pros and cons of this choice have been debated many times before in these forums, I suggest you have a search through them if you want reasons.
 
Neha Dhaka
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi :

Thanks for explaination,I know session bean are not mapped to tables in the database .I would appreciate if you can tell me what should be search criteria for the similer kind of discussion in this forum.


Raja
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raja,

Hi

I guess your question is whether to use an ejb container or not, or even more, whether one needs a servlet container at all or not. In the former I would recommend you reading this:

http://www-128.ibm.com/developerworks/library/ibm-ejb/

In the later, the answer is very simple and it all depends whether you application needs to be web enabled or not. Otherwise you can use swing and build a client-server application in the old fashion, if this fulfills your company´┐Żs needs.
Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic