hibernate 中没有做一对多 , 那种关联映射的关联的话怎么做连接查询hibernate 中没有做一对多 , 那种关联映射的关联的话怎么做连接查询hibernate 中没有做一对多 , 那种关联映射的关联的话怎么做连接查询
那这个sql运行下来符合你要求吗?
看你本身是想要做什么,left join, right join, 还是inner join?public List<Object> findElecPopedomByLoginName(final String name) {
final String sql = "SELECT a.Popedomcode FROM elec_role_popedom a " +
" LEFT OUTER JOIN elec_user_role b ON a.RoleID = b.RoleID " +
" INNER JOIN elec_user c ON b.UserID = c.UserID AND c.LoginName = ?";
List<Object> list = (List<Object>) this.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createSQLQuery(sql);
query.setParameter(0, name);
return query.list();
}
});
return list;
}