Jesper,

I tried running your test, which gives a lazy-loading exception trying to
access the Set<BeanB> from BeanA.  If you change your Hibernate mapping to
use lazy="false" then the problem goes away.

I think you will find that your OpenSessionInView filter is not opening a
session.  The net result is that a connection gets opened just long enough
to execute your get() for BeanA and then closes.

I don't have a solution for you, but it's a similar problem to trying to use
the HibernateTemplate outside of a web-app.  I have some command-line tools
that look like:

....
                this.session =
SessionFactoryUtils.getSession(sessionFactory, true);
                
        
TransactionSynchronizationManager.bindResource(sessionFactory, new
SessionHolder(session));

... do stuff with DAO's after setting template, session ...

                SessionHolder holder = (SessionHolder)
TransactionSynchronizationManager.unbindResource(sessionFactory);
                SessionFactoryUtils.releaseSession(holder.getSession(),
sessionFactory);
        

Take a look for similar lines in the OSIV filter source.
        

Jonathan



> -----Original Message-----
> From: news [mailto:[EMAIL PROTECTED] On Behalf Of Jesper Zedlitz
> Sent: Friday, February 29, 2008 9:59 AM
> To: users@tapestry.apache.org
> Subject: T5 PageTester problem (Spring and Hibernate)
> 
> Maybe someone with more detailed knowledge about Tapestry's IoC
> infrastructure can help me with this problem.
> 
> I have written a unit test (in fact it's more a kind of integration test)
> using the PageTester. Injected into the page is a DAO configured via
> Spring. If run in non-transactional mode the test works. After enabling
> the
> transaction manager the test fails.
> 
> The problem is a bit difficult to explain so I have written a small demo.
> It
> includes three test classes:
> * the first a basic page test,
> * the second with a simple Spring bean,
> * the third the problematic combination of Tapestry, Spring and Hibernate.
> http://www.comsys.informatik.uni-kiel.de/~jze/tapestry5-test.zip
> 
> With the current configuration
>   mvn test
> will fail. After commenting out the transaction manager in
> src/main/resources/applicationContext.xml all tests will work.
> 
> Jesper
> 
> --
> Jesper Zedlitz                   Dept. for Computer Science, CAU of Kiel
> Room 1108                        Communication Systems Research Group
>                                  Phone:    +49-(0)431-880-7279
> Christian-Albrechts-Platz 4      Fax:      +49-(0)431-880-7615
> 24098 Kiel - Germany             [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to