Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCEA Part2 Using DAO?

 
hagee doou
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic