I have setup my DAO as a Tapestry service in the AppModule as: public class AppModule { public static void bind(ServiceBinder binder) { binder.bind(BranchDAO.class, BranchHibernateDAO.class);
} } Then, I try to inject the session as follows: public class BranchHibernateDAO implements BranchDAO { @Inject private Session session; �...@suppresswarnings("unchecked") public Object find( Class c , BigDecimal id) { return session.get(c, id); } } I still get a NULL session. Following the suggestion by Kalle, I injected the session to a page. Then, passed the session to my DAO in the contructor. That worked! However, I would rather keep the code cleaner by injecting the session directly into the DAO. Any suggestion would be greatly appreciated. --- On Wed, 11/10/10, Kalle Korhonen <kalle.o.korho...@gmail.com> wrote: From: Kalle Korhonen <kalle.o.korho...@gmail.com> Subject: Re: session is NULL To: "Tapestry users" <users@tapestry.apache.org> Date: Wednesday, November 10, 2010, 1:48 AM @Inject is for pages. Make your DAO a Tapestry service and inject the session to it via its constructor. Kalle On Tue, Nov 9, 2010 at 9:52 PM, Anas Mughal <anasmug...@yahoo.com> wrote: > I have setup my Tapestry project using the Maven archetype. Then, I setup my > hibernate.cfg.xml file with references to my hibernate mapping files. (I am > not using annotations for hibernate.) > > Now, I have setup a simple DAO object to try to retrieve an object from the > database: > > public class BranchDAO { > > @Inject > private Session session; > > @SuppressWarnings("unchecked") > public Object find( Class c , BigDecimal id) > { > return session.get(c, id); // session is NULL here > } > } > > > I get a NULL pointer exception because my session does not seem to be > initialized. > > Searching online, I came accross: > http://wiki.apache.org/tapestry/SessionPagePersistence > > I have not setup any hivemind configuration or any of the suggested classes > on that wiki page. Please advise me what do I need to be able to fetch > objects using Tapestry-Hibernate. I don't know where to place the hivemind > configuration file -- if I need it. > > I am new to Tapestry. Please bear with me. > > Thank you for your kind assistance. > --Anas Mughal > http://anas-mughal.com > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org