Can javax.persistence.Query.getResultList() return null?

后端 未结 7 1879
心在旅途
心在旅途 2020-12-02 15:19

And if so, under what circumstances?

Javadoc and JPA spec says nothing.

7条回答
  •  臣服心动
    2020-12-02 15:44

    Given the implementation of getResultsList() in org.hibernate.ejb.QueryImpl class, it is possible to return a null :

    public List getResultList() {
        try {
            return query.list();
        }
        catch (QueryExecutionRequestException he) {
            throw new IllegalStateException(he);
        }
        catch( TypeMismatchException e ) {
            throw new IllegalArgumentException(e);
        }
        catch (HibernateException he) {
            em.throwPersistenceException( he );
            return null;
        }
    

    My hibernate version is: 3.3.1.GA

提交回复
热议问题