• Post Reply Bookmark Topic Watch Topic
  • New Topic

Connection object from EJB or DAO

 
Jimmy B Deacon
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm using stateless session EJB which uses DAO class for data manipulating.
The question is should I get DB Connection object from EJB and give it for DAO class to be used or is it better idea that DAO class would open Connection object itself and use it for data manipulating in database?

Or does it matter which one is getting the Connection object?

I read somewhere that EJB's passivate and activate method should close nad repeopen Connection when those methods are called.

So, which one is better place to open Connection from Datasource EJB or DAO?

Cheers!
 
Tim LeMaster
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would do it in the DAO. Why have the EJB do it if the EJB isn't making an Database calls?

You shouldn't be holding onto a connection so why would you need to close it and reopen it?
 
Jimmy B Deacon
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read somewhere SessionBean's passivate and activate method can close
connection and then reopen it.

That made me think that is that a feature that should be enabled.
DAO class knows nothing if EJB is thrown to disk (passivate) and reread (avtivate).

But that's I asked because I don't if this is issue taht should be
concerned.

Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!