hibernate 一个查询的写法

jintang163 2012-09-26 02:13:47
表A(用户表)
id username pwd
1 admin 123456



表B(用户信息)
id propertyname value
1 年龄 25
2 学历 本科
3 专业 电子信息工程
4 性别 男

问题:查询年龄是20岁性别为男的用户
要求用hibernate hql或DetachedCriteria查询
跪求
...全文
350 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
搞里头 2012-11-27
  • 打赏
  • 举报
回复
表都没对 还在查查查,什么都能往里放,当sqlite用啊
tc@zen123 2012-11-18
  • 打赏
  • 举报
回复
@Query("select a from A a,B b where a.id = b.userid and b.年龄='20' and b.性别 = ‘男’")
咖啡机 2012-11-17
  • 打赏
  • 举报
回复
这个表有问题吧?B表看起来像数据字典!
zhumin726 2012-11-16
  • 打赏
  • 举报
回复
select A from A,B where A.id=B.id and B.value=20
RSun01 2012-11-16
  • 打赏
  • 举报
回复
为什么这样设计表呢? 我想知道好处在哪里
xyong1325 2012-10-08
  • 打赏
  • 举报
回复
select * from user where id in(select userid from .......)

这样性能貌似不高
sei_gx 2012-09-27
  • 打赏
  • 举报
回复
hibernate 1对1不就行了吗?
select * from USER where A.B.propertyname = '性别' and ...
jintang163 2012-09-26
  • 打赏
  • 举报
回复
这样不可以的
Concern 2012-09-26
  • 打赏
  • 举报
回复
select a
from A a,B b
where 1=1
and b.a=a
and b.propertyname='性别'
and b.value='男'
and b.propertyname='年龄'
and b.value='20';
哥们,试试!
jintang163 2012-09-26
  • 打赏
  • 举报
回复
补充
表B中少了一个字段 userid

25,985

社区成员

发帖
与我相关
我的任务
社区描述
高性能WEB开发
社区管理员
  • 高性能WEB开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧