On Wed, Nov 10, 2010 at 9:42 AM, Anas Mughal <anasmug...@yahoo.com> wrote:
> > I have setup my DAO as a Tapestry service in the AppModule as: > > [...] 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. > How do you access an instance of BranchHibernateDAO? I suspect that you might create it using 'new'. That is not correct. Use Tapestry injections instead, e.g. in your page or component: @Inject private BranchDAO dao; Regards, Cezary