Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPA DAO Design Pattern

843830Mar 1 2010 — edited Mar 7 2010
Hi all,

I have one abstract DAO class and every sessionbean DAO will extend it.

here is sample code.

public abstract SuperDAO{

@PersistenceContext (unitName = "db")
private EntityManager em;

public getEM(){

return em;

}
}
Here is Session Bean DAO
@Stateless
@Local
public class CapDaoSessionBeanBean extends SuperDAO implements CapDaoSessionBeanLocal {
public CapDaoSessionBeanBean() {
}

public Customer getCustomer(){

EntityManager em = this.getEM();

}
}

My question is above design pattern is right way to get entity manager.
my idea is in all DAO we dn't need to put persistence context injection code. and just need to extend SuperDAO.
Any suggestion?

With Regards,
WP
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2010
Added on Mar 1 2010
5 comments
392 views