0 0

怎样将 sql语句 转换为 hql语句 select * from xx_order_item where order_id in (select id fr 5

order_id 是一个外键

将下面的语句转换为hql语句

select * from xx_order_item where order_id in (select id from xx_order where payment_status = 2);
2012年9月14日 13:43

6个答案 按时间排序 按投票排序

0 0

http://charyle.iteye.com/blog/1021356

2012年9月15日 13:51
0 0

不要select *
直接from 实体类名称 或者 类路径

2012年9月14日 22:05
0 0

1、把表名换成类名
2、把字段名换成属性名

2012年9月14日 16:09
0 0

使用Hibernate的时候,from的是你配置号的数据库表对应的Java POJO类名,如果你已经生成了实体类,可以通过
select * from OrderItem where OrderItem.order.payment_status=2进行查询,hibernate会自动转换成in方式的查询语句,不需要你来写。当然,你需要配置order和item之间的一对多映射关系和实体中的导航关系

2012年9月14日 16:09
0 0

select * where order_id in (select id from xx_order where payment_status = 2);

2012年9月14日 14:12
0 0

首先hibernate 支持in,你直接写只要 在相关类中有属性 order_id你发的语句完全没有问题的,
建议把类也发上来。。

2012年9月14日 13:47

相关推荐

Global site tag (gtag.js) - Google Analytics