This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes SCEA Part2 Using DAO? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "SCEA Part2 Using DAO?" Watch "SCEA Part2 Using DAO?" New topic
Author

SCEA Part2 Using DAO?

hagee doou
Greenhorn

Joined: Apr 12, 2009
Posts: 8
DAO layer is necessary between Session Bean and POJO?
I think the JPA or EntityManager is simple enough to process POJO.

Or, there are some benefits from using DAOs?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

I think the DAO pattern is one of the most important. I'd hate to see someone going directly against the entity manager. What happens if you move away from EJB? With a DAO, you can move easily. Without it, you're stuck, and that's just a very bad design.

-Cameron McKenzie
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
DAO layer is necessary between Session Bean and POJO?


If your session bean is a manager or repository type object whose sole responsibility is entity CRUD operations, then I'd say the answer is no.

I think the JPA or EntityManager is simple enough to process POJO


Only if your session bean's sole responsibility is persistence, and not business logic. Think separation of concerns and functional cohesion.

As for the traditional DAO, I'm not so sure it's that relevant with JPA / EJB3. There's no longer a need to implement abstract factories and families of DAO to cater for physical schema variations or database vendor nuances - that's all abstracted away by the ORM provider. If you do have any native queries, they can be declared in persistence.xml. There may be a case for DAOs if you're planning on moving from an RDBMS to some other form of storage but, in all honesty, how often does that happen?

What happens if you move away from EJB?


Again, how often does that happen? Why introduce another layer for something that, in all likelihood, will never happen?


SCJP, SCWCD, SCBCD, SCEA 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCEA Part2 Using DAO?
 
Similar Threads
What is this POJO
Stateless DAO(EAO) versus POJO DAO
Session beans and Dao
JPA and DAO pattern
Design issue (POJO and DTO/VO)