You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Vangel V. Ajanovski" <aj...@gmail.com> on 2021/09/11 00:07:28 UTC

hibernate session.createQuery is null when using Tapestry 5.7.3, but only in some cases

As I mentioned previously, in a contributed applicationStateManager, I 
am not able to do a session.createQuery as it returns null - the Query 
object is null.

     @Contribute(ApplicationStateManager.class)
     public void contributeApplicationStateManager(
             MappedConfiguration<Class, ApplicationStateContribution> 
configuration, final Session session, final Logger logger) {

         ApplicationStateCreator<UserInfo> userInfoCreator = new 
ApplicationStateCreator<UserInfo>() {
             public UserInfo create() {
                 Person p = (Person) session
                         .createQuery("from Person p where 
p.userName='student1'")
                         .uniqueResult();

I have done some more experiments and made it work somehow, but in an 
unexpected way.

I found out that:

- session.createQuery() - returns null, whatever the query

- session.get(Person.class, id) - works OK, which means the session and 
the connection to the database is OK

After many trials, I managed to find a way to run a query

- either like this:

session.getSession().createQuery()

- or like this:

session.getSessionFactory().openSession()

Somehow I don't think that I am supposed to do that. Any ideas?



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