HQL多表联合查询的问题 HQL查询多表的时候,取出结果是两个对象的列表,但是我只要我自己想要的属性,之前的HQL语句是这样写的:

结果我debug去看query.list();是Hytxbz和Tgbzk两个对象的列表,结果并不是我想要的,我改成

还是不行,google一把,发现可以这样写

如果想取得对应属性的话,也可以这样写

发现in的语句可以这样写


String hql
=
"
from com,you.YourPOJO where id in (?)
"
;


Query query
=
session.createQuery(hql);

query .setParameters(ids);


相关方法:


Query setParameters(Object[] objectArray, Type[] typeArray)
throws
HibernateException;

Query setParameterList(String string, Collection collection, Type type)
throws
HibernateException;

Query setParameterList(String string, Collection collection)
throws
HibernateException;

Query setParameterList(String string, Object[] objectArray, Type type)
throws
HibernateException;

Query setParameterList(String string, Object[] objectArray)
throws
HibernateException