HQL语句多表联合查询的视图
2017-05-10 11:28
239 查看
HQL语句多表联合查询
StringBuilder hqlsb1=new StringBuilder("select distinct f from TSFunction f,TSRoleFunction rf,TSRoleUser ru ").append("where ru.TSRole.id=rf.TSRole.id and rf.TSFunction.id=f.id and ru.TSUser.id=? ");
StringBuilder hqlsb2=new StringBuilder("select distinct c from TSFunction c,TSRoleFunction rf,TSRoleOrg b,TSUserOrg a ")
.append("where a.tsDepart.id=b.tsDepart.id and b.tsRole.id=rf.TSRole.id and rf.TSFunction.id=c.id and a.tsUser.id=?");
List<TSFunction> list1 = systemService.findHql(hqlsb1.toString(),user.getId());
List<TSFunction> list2 = systemService.findHql(hqlsb2.toString(),user.getId());
StringBuilder hqlsb1=new StringBuilder("select distinct f from TSFunction f,TSRoleFunction rf,TSRoleUser ru ").append("where ru.TSRole.id=rf.TSRole.id and rf.TSFunction.id=f.id and ru.TSUser.id=? ");
StringBuilder hqlsb2=new StringBuilder("select distinct c from TSFunction c,TSRoleFunction rf,TSRoleOrg b,TSUserOrg a ")
.append("where a.tsDepart.id=b.tsDepart.id and b.tsRole.id=rf.TSRole.id and rf.TSFunction.id=c.id and a.tsUser.id=?");
List<TSFunction> list1 = systemService.findHql(hqlsb1.toString(),user.getId());
List<TSFunction> list2 = systemService.findHql(hqlsb2.toString(),user.getId());
相关文章推荐
- HQL语句多表联合查询,Mysql不设置外键关系
- sqlserver 数据库写hql语句时,联合查询查的语句要用括号括起来!
- 对多表联合查询的SQl语句的改进,大幅提高查询性能
- hibernate查询语句--HQL
- 数据库语句大全之联合语句UNION/内连接查询/外连接查询
- hql查询语句
- 求一个高级MSSQL视图查询语句-望大虾指教
- 又一个通用分页存储过程,支持表别名,多表联合查询SQL语句--转载
- sql语句的联合查询(join 用法)
- Castle学习笔记----使用HQL语句实现复杂查询
- 对多表联合查询的SQl语句的改进,大幅提高查询性能 (转)
- HQL语句查询中一些参数设置的问题
- 又一个通用分页存储过程,支持表别名,多表联合查询SQL语句
- hibernate查询语句--HQL
- hibernate查询语句--HQL
- hibernate里使用hql语句处理多表查询
- hibernate查询语句--HQL(转自CSDN)
- 简单查询和联合查询两方面介绍SQL查询语句
- sql语句的联合查询(join 用法)
- Hibernate的HQL查询语句对比Sql语句学习