Query query = this.getEntityManager().createQuery("select o FROM Order o where o.orderId = :id");
query.setParameter("id",String.valueOf(id));//在setParameter的时候,第二个参数的类型要和orderId的类型一致,否则要报如下错误
result=(Order) query.getSingleResult();
could not bind value '21' to parameter: 1; java.lang.String
java.lang.ClassCastException: java.lang.String
query.setParameter("id",String.valueOf(id));//在setParameter的时候,第二个参数的类型要和orderId的类型一致,否则要报如下错误
result=(Order) query.getSingleResult();
could not bind value '21' to parameter: 1; java.lang.String
java.lang.ClassCastException: java.lang.String