• Post Reply Bookmark Topic Watch Topic
  • New Topic

When it is appropiate to have a EJB layer for doing database operations .

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on EJB Project , i am working on a existing code which was developed in 2005 .

The EJB version used is 2.1

In this code ,
sometimes data from Database is retrivied /inserted using EJB(Using JDBC internally) and sometimes this is done using plain JDBC , i mean without EJBLayer in between


Please tell me in whcih scenario , it is appropiate to have a EJB layer for doing database operations .

Thanks in advance .



 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use EJBs when you need to sue the container provided services they can access.


sometimes data from Database is retrivied /inserted using EJB(Using JDBC internally) and sometimes this is done using plain JDBC

This just sounds like poor coding.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Paul .

As per the point you made :
You use EJBs when you need to sue the container provided services they can access.


My question is , it is better to have container provide services for DML operations or for also select statements .

Please advise , thank you .

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends. Does you application need any of these services?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does you application need any of these services?


Ya we have have some static data confiured in Database tables required for Java classes , so please tell me generally what does It depends mean exactly ??




 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, not following. What container provided services does the existence of static data in your application imply the need for?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul , thanks for the reply .
I have changed my question , my question is

For Select statements does does a EJB Layer is necessary ??

Please share your ideas , thanks in advance .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, no, you just need JDBC for that.

But then, its not a question anyone should be using to choose between using EJBs or not.
 
Prabhakar Reddy Bokka
Ranch Hand
Posts: 197
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran Pattu wrote:
For Select statements does does a EJB Layer is necessary ??


Ravi Kiran,

First you need to understand what are the services provided by Container.
Then if your application needs those services, you will go for that. Its just not JDBC.
You can make JDBC calls from EJB(session beans) also.
Using Entity beans is not adviced for just retrival of data.
When working with JMS, MDB makes sence.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!