执行查询时出现错误。错误是:
java.lang.IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:在第 1 行附近开始,第 84 列 [来自 com.services.om.entity.OrderLines,其中 orderNumber in (:order_Numbers) 以 parentLineIdentifier 开头null 通过先前 orderLineIdentifier = parentLineIdentifier 连接]
我的 DAO 代码是:
public List<OrderLineVO> findAllOrders(List<BigDecimal> orderNumbers) throws OrderManagementException {
try{
String getAllOrders = "from OrderLines where orderNumber in (:order_Numbers) order by orderDate desc ";
Query query = em.createQuery(getAllOrders,OrderLines.class);
query.setParameter("order_Numbers", orderNumbers);
List<OrderLines> orderLinesList = query.getResultList();
String queryParentChild = "from OrderLines where orderNumber in (:order_Numbers) start with parentLineIdentifier is null connect by prior orderLineIdentifier = parentLineIdentifier";
Query queryParent = em.createQuery(queryParentChild, OrderLines.class);
queryParent.setParameter("order_Numbers", orderNumbers);
List<OrderLines> orderLinesList2 = queryParent.getResultList();
return OrderLineUTIL.getOrderLines(orderLinesList);
}catch(Exception exception){
logger.error(exception.getMessage());
throw new OrderManagementException(exception.getMessage());
}
}
em.createQuery(queryParentChild, OrderLines.class); // Line is giving above error.
有什么建议吗?
实体类字段变量也在查询中正确标记。