0

错误:

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.Orders orders INNER JOIN orders.OrderProcessing as op ON op.u_id = orders.u_id INNER JOIN orders.Product 作为产品 ON product.p_id = orders.p_id WHERE product.p_id = '208' ORDER BY操作用户名]

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();
4

3 回答 3

1

Hibernate 支持连接限制,但语法与 SQL 不同。您必须在 Hibernate中替换ON关键字!WITH

于 2013-02-26T08:34:03.330 回答
0

Chetter Hummin 是对的,HQL 不支持“开”。看到这个:http ://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html

于 2013-02-26T07:07:13.383 回答
0
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();

您必须检查订单表。orders.orderProcessing 不是一个表,它是 orders 表中的一列。

于 2013-02-26T06:45:45.983 回答