求助帖,关于我这个HQL该怎么写
本帖最后由 hedong0112 于 2013-12-18 15:26:43 编辑




求助:群组管理,我要在给群组中添加成员,添加一条出现了多条,删除第一条也会删除全部,首先我的插入功能有问题,再者我的查询有问题。以下是我的查询HQL
String hql = "select gu.sysNo,g.groupName,u.loginname,"
+ "gu.createdTime,gu.modifiedTime,c.companyName "
+ "Groups as g,"
+ "Users as u,"
+ "GroupUser as gu,"
+ "Company as c "
+ "where c.companyCode=g.companyCode and "
+ "c.companyCode=u.companyCode and "
+ "c.companyCode=gu.companyCode ";
请问这个HQL怎么改? 这是四张表,他们中 都有companyCode这个字段,group,group_user,users,company。
------解决方案--------------------你这个就是sql 查询,不是hql。 和插入删除没有关系。
------解决方案--------------------把这句转换过的sql放到数据库执行。 hibernate有打印sql
------解决方案--------------------
那就把sql调试到想要的结果。然后在翻译成hql,不就搞定了吗?
------解决方案--------------------1+n问题。。