hibernate 超级经典的左右连接

hibernate 里面的left join 解决办法 转换成实体

String hql = "select a.user_phone as terminal,a.user_gps_time as upTime,a.user_addtime as createTime,a.user_cfg_control as isLogout,b.organ_name as orgName from gota_user a left join sys_organ b on  a.user_com_id = b.organ_id order by a.user_phone";
Query query=session.createSQLQuery(hql).addScalar("terminal", Hibernate.STRING).addScalar("upTime", Hibernate.DATE).addScalar("createTime", Hibernate.DATE).addScalar("isLogout", Hibernate.STRING).addScalar("orgName", Hibernate.STRING).setResultTransformer(Transformers.aliasToBean(TerminalEntity.class));

你可能感兴趣的:(Hibernate)