[jboss-user] [EJB 3.0] - Re: EntityManagers and DAOs

chrismeadows do-not-reply at jboss.com
Fri Nov 10 04:26:08 EST 2006


"ALRubinger" wrote : 
  | ...if you set stuff in a ThreadLocal, ensure that its removed if the Thread has been obtained from a Thread pool.  Otherwise, nightmares.
  | 

Thanks ALR, I'll watch out for that

"ALRubinger" wrote : 
  | Or in your case...if you don't want to put any JPA stuff in your DAO APIs...why not just pass the EM into the DAOImpl Constructor?
  | 

DAOImpls are currently singleton per DAO iface, but must be thread safe, so I'm using ThreadLocal rather than passing in via method parameters.

I could stop using a singleton and create a DAOImpl per DAO request (as you suggest), but then I have a proliferation of DAOs just to ensure thread safety which smells of an antipattern. 

Thank you for your comments everyone.

C

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3984828#3984828

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3984828



More information about the jboss-user mailing list