Hibernate在query.list()上给出NullPointerException

时间:2019-03-21 10:06:26

标签: hibernate-5.x jboss-eap-7

我在持久性XML中使用JTA事务类型 从堆栈跟踪看起来好像休眠正在尝试在发生NPE时释放连接?

知道为什么会导致问题吗,这是休眠错误吗?

这是堆栈跟踪:

Caused by: java.lang.NullPointerException
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.closeConnection(DatasourceConnectionProviderImpl.java:127)
    at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.releaseConnection(AbstractSessionImpl.java:397)
    at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:169)
    at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.afterStatement(LogicalConnectionManagedImpl.java:122)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterStatementExecution(JdbcCoordinatorImpl.java:287)
    at org.hibernate.loader.Loader.doQuery(Loader.java:948)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
    at org.hibernate.loader.Loader.doList(Loader.java:2622)
    at org.hibernate.loader.Loader.doList(Loader.java:2605)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2434)
    at org.hibernate.loader.Loader.list(Loader.java:2429)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:370)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1339)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
    at com.abc.app.bha.dataaccess.dao.quote.HibernateQuoteDAO.getNumberOfLives(HibernateQuoteDAO.java:164)
    at com.abc.app.bha.appservice.manager.QuoteManager.getNumberOfLives(QuoteManager.java:328)
    at com.abc.app.bha.appservice.manager.QuoteManager.getProductCategoryDetails(QuoteManager.java:448)
    at com.abc.app.bha.appservice.ejb.GroupRiskServiceBean.getProductCategoryDetails(GroupRiskServiceBean.java:166)
    at sun.reflect.GeneratedMethodAccessor447.invoke(Unknown Source)

这是我调用list()方法的方法

public List getNumberOfLives(Long objQuoteId) {

        List toReturn = null;
        try {
            Query locQuery = this.getHibernateSession().createQuery(
                    HQL_NUM_LIVES);
            locQuery.setParameter("quoteId", objQuoteId);
            toReturn = locQuery.list();
        } catch (HibernateException hbnExp) {
            Util.error(LOG, hbnExp);
            throw new DataAccessException(hbnExp);
        }


        return toReturn;
    }

0 个答案:

没有答案