将oracle查询转换为JPQL查询......!

时间:2016-06-30 12:25:36

标签: java sql oracle jpa jpql

我有像这样的口头查询

select * from CBH.MCBH_BABY_INFO mbc 
 where 
 MBC.MARKETINGCBHID in (625588,4238636,5220648) 
 and (MBC.WERKELIJKE_GEBOORTEDATUM is null or  MBC.WERKELIJKE_GEBOORTEDATUM >(sysdate-30));

我将此查询转换为JPQL查询,如此

QUERY_SEL_BY_MCBH_ID_LIST = "SELECT mc FROM MarketingCbhBabyInfo mc "+
                                                           "WHERE mc.marketingCbh.id in :mcbhIdList"+
                                                            "AND (mc.WERKELIJKE_GEBOORTEDATUM IS NULL "+
                                                            "OR mc.WERKELIJKE_GEBOORTEDATUM >(CURRENT_DATE-:days))";

在DAO课程中我传递了idlist和这样的日子。

List<MarketingCbhBabyInfo> marketingCbhBabyInfoList = this.em.createNamedQuery(MarketingCbhBabyInfo.SEL_BY_MCBH_ID_LIST,MarketingCbhBabyInfo.class)
                                                             .setParameter("mcbhIdList",mcbhIdList)
                                                             .setParameter("days",days)
                                                             .getResultList();


I have converted the above query to jpql query but it is giving me

 Filter invalid. Cannot compare field realBirthDate of type java.util.Date to value of type java.lang.Number. Numeric comparisons must be between numeric types only. To enable such comparisons for backwards-compatibility, add "QuotedNumbersInQueries=true" to the org.apache.openjpa.Compatibility setting in your configuration.
    at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.convertTypes(AbstractExpressionBuilder.java:435)

0 个答案:

没有答案