简体   繁体   English

错误:org.hibernate.hql.ast.QuerySyntaxError:意外令牌

[英]Error: org.hibernate.hql.ast.QuerySyntaxError: unexpected token

Error: 错误:

org.hibernate.hql.ast.QuerySyntaxError: unexpected token org.hibernate.hql.ast.QuerySyntaxError: unexpected token: ON near line 1, column 148 [SELECT op.username, op.email, orders.p_id, orders.o_id, product.listed_price FROM com.model.Orders orders INNER JOIN orders.OrderProcessing as op ON op.u_id = orders.u_id INNER JOIN orders.Product as product ON product.p_id = orders.p_id WHERE product.p_id = '208' ORDER BY op.username] org.hibernate.hql.ast.QuerySyntaxError:意外令牌org.hibernate.hql.ast.QuerySyntaxError:意外令牌:在第1行第148列附近打开[SELECT op.username,op.email,orders.p_id,orders.o_id, product.listed_price FROM com.model op.username]

productList = 
(List<Object[]>) session.createQuery("SELECT op.username, op.email, orders.p_id, orders.o_id, product.listed_price " + 
"FROM Orders  orders " +
"INNER JOIN orders.OrderProcessing as op " +                                                        
"ON op.u_id = orders.u_id " +                                                              
"INNER JOIN orders.Product as product " +                                                               
"ON product.p_id = orders.p_id " +                                                         
"WHERE product.p_id = '"+p_id +"' " +                                                          
"ORDER BY op.username").list();

Join restrictions are supported by Hibernate but the syntax is not the same than SQL. Hibernate支持联接限制,但是语法与SQL不同。 You have to replace the ON keyword by WITH in Hibernate ! 在Hibernate中,您必须用WITH替换ON关键字!

productList = (List<Object[]>) session.createQuery("SELECT op.username, op.email, orders.p_id, orders.o_id, product.listed_price " + "FROM Orders  orders " +"INNER JOIN orders.OrderProcessing as op " +  "ON op.u_id = orders.u_id"+ "INNER JOIN orders.Product as product " + "ON product.p_id = orders.p_id "+ "WHERE product.p_id = '"+p_id +"'" "ORDER BY op.username").list();

You have to check the Orders table. 您必须检查订单表。 orders.orderProcessing is not a table its a column from orders table. orders.orderProcessing不是一个表,它是orders表的一列。

Chetter Hummin is right, "on" isn't supported in HQL. Chetter Hummin是正确的,HQL不支持“ on”。 See this: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html 看到这个: http : //docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hibernate:org.hibernate.hql.ast.QuerySyntaxException:意外令牌 - Hibernate: org.hibernate.hql.ast.QuerySyntaxException: unexpected token org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌 - org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:FETCH - org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: FETCH org.hibernate.hql.ast.QuerySyntaxException:意外令牌: - org.hibernate.hql.ast.QuerySyntaxException: unexpected token: org.hibernate.hql.internal.ast.ErrorCounter:意外令牌:( - org.hibernate.hql.internal.ast.ErrorCounter: unexpected token: ( org.hibernate.hql.ast.QuerySyntaxException:意外令牌 - org.hibernate.hql.ast.QuerySyntaxException: unexpected token 休眠:org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:(靠近第1行,第6列…) - Hibernate: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 6…) Hibernate查询语法异常:org.hibernate.hql.ast.QuerySyntaxException:意外令牌 - Hibernate Query Syntax exception : org.hibernate.hql.ast.QuerySyntaxException: unexpected token 错误:org.hibernate.hql.internal.ast.ErrorCounter - 第 1:45 行:意外标记:从表中获取最后一条记录时出现 DESC - ERROR: org.hibernate.hql.internal.ast.ErrorCounter - line 1:45: unexpected token : DESC on fetching the last record from the table Postgresql- Hibernate查询语法异常:org.hibernate.hql.ast.QuerySyntaxException:附近的意外令牌 - Postgresql- Hibernate Query Syntax exception : org.hibernate.hql.ast.QuerySyntaxException: unexpected token at near
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM