这不是一个“问题”,因为一切工作正常,但它真的令人难以置信,它工作正常,我无法找到答案。HQL ArrayList返回多个类的类型
所以我有一些简单的休眠HQL查询:
List<Comment> commentList = session.createQuery("select c, u from Comment as c, User as u where c.postRef.id = :post_id").setParameter("post_id", postId).getResultList();
当它运行时,我期待在调试器返回,看起来像这样的commentList
:
- commentList - "ArrayList<E>",
- elementData - Object[10]
- [0] - Object[2]
- [0] Comment
- [1] User
- [1] - null
- [2] - null ... (etc, to the end it's null)
而我只是不能了解它,在这ArrayList<E>
中有什么可能有两种类型的对象? Comment
和User
在一个ArrayList
中,我可以假设这是创建对象的东西ArrayList
,但是这怎么可能返回ArrayList<Object>
到List<Comment>
没有抛出任何异常?然后我的方法也是返回类型public List<Comment>
,我返回这个确切的commentList
,并且一切正常工作。
感谢任何帮助。