Hi,

The awesome thing is that everything in Tapestry can be a service! All you need 
is a service builder method and the @Inject annotation in your Services, Pages 
and Components. 

So for a hibernate session you could (not saying this is a good solution, but 
it's a start) a service builder method for Session in the application module 
like so:

@Scope(PER_THREAD) // means every thread will get it's own instance
public Session buildSession( @Inject PerThreadManager,  @Inject SessionFactory 
){
      Session session = // setup session here;
  
      // clean up session at the end of request
      perthreadManager.addThreadCleanupListener(new ThreadCleanupListener() {

            @Override
            public void threadDidCleanup() {
                    session.close();
            }
        });
      return session;
}


For this to work you need to do the same thing for SessionFactory as well. 


In your Pages/Components/Services you can then simply write:

@Inject
private Session session;

I hope this illustrates the general principle.


Kind Regards,
Wulf

-----Original Message-----
From: esper [mailto:marin_ma...@yahoo.com] 
Sent: Freitag, 12. Oktober 2012 11:47
To: users@tapestry.apache.org
Subject: Tapestry & hibernate session - without tapestry-hibernate module

Hi good people,

i'm trying to get tapestry working with pure hibernate (no
tapestry-hibernate module involved).
With tapestry-hibernate you just inject a session into your components but
how does it work without the module? Where do I initialize my session
object? I don't want to do this heavy operation every time the component
gets called!

is there a good documentation on how to do this you can point me to?



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Tapestry-hibernate-session-without-tapestry-hibernate-module-tp5716838.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to