Hi Greg,
I believe Brian is correct.
You need to wrap BookDao.find(...) within a transaction or use
OpenSessionInView.
Either one of these should keep the session open when you are navigating the
object graph
in your DAO. If you use OSIV (OpenSessionInView) filter, then you can
navigate the
object graph in your web tier as well.
We are using both OpenSessionInView filter and a service layer which acts as
a facade to the data layer (DAOs). The services are annotated with
@Transactional (although for readOnly transactions this is really
unnecessary within the OSIV scope; but they are there for consistency).
/robert
----- Original Message -----
From: "Brian Thompson" <elephant...@gmail.com>
To: "Struts Users Mailing List" <user@struts.apache.org>;
<lukasz.len...@gmail.com>
Sent: Monday, July 19, 2010 1:22 PM
Subject: Re: struts2+hibernate+spring - lazyInitaializationException
Looks to me like the session is being closed in the scope of
hibernateTemplate.get().
I don't see a transactionManager mentioned in the XML ... you could
try adding something like this in the XML configuration file:
<bean id="transactionManager"
class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
n.b. I haven't tested the above config, so it probably won't work
as-is. Hopefully it helps, though.
-Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org