-
1. Re: Spring-injected ManagedHibernateSession
berserksangr Nov 17, 2006 10:53 AM (in response to berserksangr)Can this be achieved by the following?
1. Configure DataSource and Hibernate session factory using Spring
2. Bind this session factory to JNDI under java:/sessionFactory
3. Spawn HibernateManagedSession in components.xml and set sessionFactoryJndiName to java:/bookingSessionFactory
4. When DAO method is invoked, get HibernateSession using Seam's Contexts.lookupInStatefulContexts(HibernateManagedSession_COMPONENT_NAME).
TIA -
2. Re: Spring-injected ManagedHibernateSession
gavin.king Nov 17, 2006 11:24 AM (in response to berserksangr)You need three things, AFAICT:
(1) an way to get the sessionfactory into JNDI, so Seam can use it
(2) a way to inject Seam objects into non-Seam objects
(3) a JTA environment
(1) is easy
(2) is be doable with some spring factories, AFAIK
(3) is the harder bit (problem when outside-of-Java-EE)
Unfortunately for everyone, Spring went ahead and created their whole own nonstandard transaction management API that is a subset of JTA (there was no good reason to do this, of course, but people like to reinvent wheels).
Seam expects a JTA environment (I *don't* like reinventing), and thats what we use JBoss MC for: the JTA and JCA datasource support. With some effort I probably *could* support other transaction APIs than JTA, but why? There is just no good reason to do that, since all transaction APIs that I know of offer less functionality than JTA.
(People have misinterpreted JBoss MC as being a spring-like project but actually its purpose is quite different. The purpose of MC is to let you run infrastructure components like deployers, jta, jca, jndi, etc in an embeddable way. It not really intended for running business logic components. It is really the core microkernel of JBoss 5.)
Now, in a Java EE environment, you already have JTA from the container (and, indeed Spring transactions just map down to JTA transactions, duh). So Seam does not need MC in an EE environment. So in the EE environment, (3) is not a problem.
Outside the EE environment you got a problem, and you need JBoss MC. -
3. Re: Spring-injected ManagedHibernateSession
berserksangr Nov 18, 2006 9:20 AM (in response to berserksangr)Gavin, thank you for such a quick and useful response. I think I will try with MC.
Thanks for your hard work,
Przemek.