Hibernate - Session.createQuery(String) 升级后返回 null

问题描述 投票:0回答:0

升级了运行 Tapestry v5.4.5 -> v5.8.2 的旧应用程序,我们遇到了 Hibernate/HQL 查询问题。

像这样的查询曾经有效

session.createQuery("from MyEntity", MyEntity.class)

现在抛出异常:

java.lang.NullPointerException: Cannot invoke "org.hibernate.query.Query.list()" because the return value of "org.hibernate.Session.createQuery(String, java.lang.Class)" is null

我们所有的Hibernate都在

hibernate.cfg.xml

有人知道为什么会这样吗?

作为一个有趣的事实,使用

EntityManager
似乎工作正常:

session.getEntityManagerFactory()
                .createEntityManager()
                .createQuery("select e from MyEntity e", MyEntity.class)
                .getResultList()
    
hibernate jpa hql tapestry
© www.soinside.com 2019 - 2024. All rights reserved.