hibernate的HQL查询部分属性

HQL查询部分属性,特别是一个中间表,对应的有外键,即要查询的表,对应的model是包含对象属性,如果只是查询对象属性,需要为该对象添加别名

如:

//错误:
session().createQuery("select resource from ProxyResource where proxy.id = "+id);

//正确:
session().createQuery("select p.resource from ProxyResource p where p.proxy.id = "+id);




你可能感兴趣的:(Hibernate,HQL查询)