[jboss-user] [JBoss Seam] - Re: PersistenceContext injection in Seam 2.0beta1

alexg79 do-not-reply at jboss.com
Sat Aug 11 10:52:58 EDT 2007


anonymous wrote : @PersistenceContext is part of JPA, why would it be able to inject a Hibernate Session.
Further proof here:
http://docs.jboss.com/ejb3/app-server/reference/build/reference/en/html/hibernate.html
anonymous wrote : 
  | 4.2. Injection Hibernate Session and SessionFactory
  | 
  | You can inject a org.hibernate.Session and org.hibernate.SessionFactory directly into your EJBs just as you can do with EntityManagers and EntityManagerFactorys. The behavior of a Session is just the same as the behavior of an injected EntityManager. The application server controls the lifecycle of the Session so that you do not have to open, flush, or close the session. Extended persistence contexts also work with injected Hibernate Sessions.
  | 
  | import org.hibernate.Session;
  | import org.hibernate.SessionFactory;
  | 
  | @Stateful public class MyStatefulBean ... {
  |    @PersistenceContext(unitName="crm") Session session1;
  |    @PersistenceContext(unitName="crm2", type=EXTENDED) Session extendedpc;
  |    @PersistenceUnit(unitName="crm") SessionFactory factory;
  |          
  | }

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

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



More information about the jboss-user mailing list