enter code here
您好我正在使用实体管理器(EJB),它在内部依赖于hibernate来获取Object。
我的查询是........
TypedQuery<FraudDetectionInfoEntity> queryKount = em_oltp.createQuery("SELECT o FROM FraudDetectionInfoEntity o WHERE o.order.orderId=:orderId",FraudDetectionInfoEntity.class);
query.setParameter("orderId", orderEntity.getOrderId());
FraudDetectionInfoEntity infoEntity=queryKount.getSingleResult();
我收到了以下错误如果我运行该查询。
org.hibernate.QueryParameterException: could not locate named parameter [orderId]
org.hibernate.QueryParameterException: could not locate named parameter [orderId]
12:46:58,639 ERROR [com.vip.enterprise.admin.web.controller.OrderPlacementController] (http-/127.0.0.1:8084-6) error com.vip.enterprise.service.exception.ServiceException: org.hibernate.QueryParameterException: could not locate named parameter [orderId]
12:47:00,001 ERROR [com.vip.enterprise.service.jobs.ReplenishmentJob] (EJB default - 4) Replenish Orders JOB : Mon Jan 27 12:47:00 IST 2014
答案 0 :(得分:0)
您的代码没问题。缺少变量query
或queryKount
?
TypedQuery<FraudDetectionInfoEntity> queryKount = em_oltp.createQuery("SELECT o FROM FraudDetectionInfoEntity o WHERE o.order.orderId=:orderId",FraudDetectionInfoEntity.class);
query.setParameter("orderId", orderEntity.getOrderId());
<or>
queryKount.setParameter("orderId", orderEntity.getOrderId());