Forums Register Login

SCEA Part2 Using DAO?

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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?
The knights of nee want a shrubbery. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1358 times.
Similar Threads
Session beans and Dao
JPA and DAO pattern
Design issue (POJO and DTO/VO)
What is this POJO
Stateless DAO(EAO) versus POJO DAO
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:58:04.