That's not exactly a good separation of concerns, though.  Your view
layer shouldn't be talking directly to your ORM layer.  I'd put a DAO
layer in between for some encapsulation (and to help with unit
testing).


On 2/26/07, Massimo Lusetti <[EMAIL PROTECTED]> wrote:
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]



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

Reply via email to