On 2/25/07, Olivier Jacquet <[EMAIL PROTECTED]> wrote:


Hi,


Does anyone has an example of how to get tapestry, jetty and hibernate
running together?

Having an hibernate Session injected into T5 pages is fairly easy:

public final static SessionFactory buildSessionFactory()
   {
       URL res = AppModule.class.getResource("/hibernate.cfg.xml");
       SessionFactory sf = new AnnotationConfiguration()
                               .configure(res)
                               .buildSessionFactory();

       return sf;
   }


   @Lifecycle("perthread")
   public Session buildSession(@InjectService("SessionFactory")
                               SessionFactory factory)
   {
       return factory.getCurrentSession();
//        return factory.openSession();
   }


Then in you page just:

 @Inject
 private Session _session;

I think all of these is explained in the online doc.

If you need/wish more integration (like having your hibernate object
directly into your pages) you have to do some more work, this is just
a starting point.

--
Massimo
http://meridio.blogspot.com

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

Reply via email to