For example, the following query:
{code}movies = em.createQuery( "from Movie where title in (:titles) and viewerRating in (:ratings)", Movie.class ) .setParameter( "titles", Arrays.asList( "Barnie", "Front Door", "To thatch a roof" ) ) .setParameter( "ratings", Arrays.asList( (byte) 6, (byte) 7 ) ) .getResultList();{code}
causes the following error on execution:
{code}javax.cache.CacheException: Failed to execute map query on the node: 2d1656dd-293e-495e-aec5-84223e9ab1cd, class org.apache.ignite.IgniteCheckedException:Failed to execute SQL query. Data conversion error converting "Front Door"; SQL statement: SELECT _GEN_0___Z0._KEY __C0_0, _GEN_0___Z0._VAL __C0_1 FROM PUBLIC.MOVIE _GEN_0___Z0 WHERE (_GEN_0___Z0.TITLE IN(?1, ?2, ?3)) AND (_GEN_0___Z0.VIEWERRATING IN(?4, ?5)) [22018-195] at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.fail(GridReduceQueryExecutor.java:275) at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.onFail(GridReduceQueryExecutor.java:265) at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.onMessage(GridReduceQueryExecutor.java:244) at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.sendError(GridMapQueryExecutor.java:871) at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onQueryRequest0(GridMapQueryExecutor.java:734) at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onQueryRequest(GridMapQueryExecutor.java:516) at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onMessage(GridMapQueryExecutor.java:214) at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor$1.applyx(GridReduceQueryExecutor.java:154) at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor$1.applyx(GridReduceQueryExecutor.java:152) at org.apache.ignite.internal.util.lang.IgniteInClosure2X.apply(IgniteInClosure2X.java:38) at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.send(IgniteH2Indexing.java:2555) at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.send(GridReduceQueryExecutor.java:1419) at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:732) ... 45 more{code}
This happens because actual parameter values are passed in wrong order, not in any way following parameter's positions (?1, ?2...).
This bug may occur not only when IN predicate is used, but in any query with multiple named parameters. As a result, it may cause type conversion exception, or wrong return result -- if all values match types, but are misordered. |
|