各位好,今天用了一下IN()操作符,但是报错,请大家帮忙看一下,我用的是Hibernate 3以上版本。代码摘要:String itemsql = "from Item i in(i.bids) b where b.amountCurrency >200 ";
List itemList = secondSession.createQuery(itemsql).list();错误摘要:Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: unexpected token: in near line 1, column 28 [select i from hello.Item i in(i.bids) b where b.amountCurrency >200 ]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
List itemList = secondSession.createQuery(itemsql).list();错误摘要:Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: unexpected token: in near line 1, column 28 [select i from hello.Item i in(i.bids) b where b.amountCurrency >200 ]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
解决方案 »
- simple_list_item_multiple_choice 里边的CheckBox
- JDBC操作mysql。得到一个结果集,如何定位到这个结果集的某一行?
- 求助一个用Expect实现的自动交互问题
- 请问一个关于XSL表达式的问题!
- 如何用JAVA代码查看文件夹中的变化
- 请高手指点一下我这个java的初哥,关于java调用oracle储存过程的问题?
- hibernate<many-to-many>删除问题?
- 求struts+hibernate分页
- 请教,用weblogic6时Oracle和SqlServer驱动哪里找?
- 出现事务已提交没有活动的事务,导致无法调用数据库如何解决??
- ajax
- spring 任务调度,定时器没有正确执行
大概意思是出出价金额大于200的所有已出价的商品和出价的信息。
FROM Item i, IN(i.bids) b WHERE b.amountCurrency > 200
OK! 测试后通过。Hibernate 实战(第二版),书中摘要: HQL和JPA QL提供另外一种语法,用于在FROM子句中连接集合,并给它分配一个别名。
这个IN()操作符在更早版本的EJB QL中就出现了。
它的语义与普通集合连接的一样。
from Item i,in(i.bids) b 生成了与上面的示例中用from Item i join i.bids b一样的内部连接。谢谢各位的支持!