当我们将marketOfferId
的值设置为setParameter
时,它不会返回结果。但是当我用查询中的单引号将:marketOfferId
替换为实际值时,它正在运行' BDEN3F'。有人可以帮我解释是什么原因吗?
String iden = "BDEN3F";
TypedQuery query = em.createNamedQuery(namedQuery,MarketingOfferWEB.class).setParameter("marketOfferId",iden);
- 不工作
@NamedNativeQuery(name = MarketingOfferWEB.FIND_WEB_MARKETOFFER, query = "SELECT * FROM VW_WEB_MKT_OFFERS WHERE MKT_OFFER_UID = :marketOfferId AND TENANT_ID=1", resultClass = MarketingOfferWEB.class)
- 工作
@NamedNativeQuery(name = MarketingOfferWEB.FIND_WEB_MARKETOFFER, query = "SELECT * FROM VW_WEB_MKT_OFFERS WHERE MKT_OFFER_UID = 'BDEN3F' AND TENANT_ID=1", resultClass = MarketingOfferWEB.class)
答案 0 :(得分:0)
我已经通过从TypedQuery更改为Query来解决了这个问题。
查询query = em.createNamedQuery(namedQuery,MarketingOfferWEB.class).setParameter(“marketOfferId”,iden);