• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

SCEA Part2 Using DAO?

 
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?
 
author and cow tipper
Posts: 5000
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
 
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?
 
Beware the other head of science - it bites! Nibble on this message:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!