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 h2 . ignite jdbc . IgniteCheckedException JdbcSQLException : 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 h2 . ignite message . internal DbException . processors getJdbcSQLException(DbException . query java:345) at org .h2. twostep message . GridReduceQueryExecutor DbException . fail get ( GridReduceQueryExecutor DbException .java: 275 168 ) at org. apache h2 . ignite value . internal Value . processors convertTo(Value . query java:996) at org .h2. twostep expression . GridReduceQueryExecutor ConditionIn . onFail getValue ( GridReduceQueryExecutor ConditionIn .java: 265 56 ) at org. apache h2 . ignite expression . internal ConditionAndOr . processors getValue(ConditionAndOr . query java:93) at org .h2. twostep expression . GridReduceQueryExecutor Expression . onMessage getBooleanValue ( GridReduceQueryExecutor Expression .java: 244 178 ) at org. apache h2 . ignite command . internal dml . processors Select . query isConditionMet(Select . java:299) at org. h2. twostep command . GridMapQueryExecutor dml . sendError Select.access$600 ( GridMapQueryExecutor Select .java: 871 64 ) at org. apache h2 . ignite command . internal dml . processors Select$LazyResultQueryFlat . query fetchNextRow(Select . java:1455) at org. h2. twostep result . GridMapQueryExecutor LazyResult . onQueryRequest0 hasNext ( GridMapQueryExecutor LazyResult .java: 734 79 ) at org. apache h2 . ignite result . internal LazyResult . processors next(LazyResult . query java:59) at org .h2. twostep command . GridMapQueryExecutor dml . onQueryRequest Select.queryFlat ( GridMapQueryExecutor Select .java: 516 519 ) at org. apache h2 . ignite command . internal dml . processors Select . query queryWithoutCache(Select . java:625) at org. h2. twostep command . GridMapQueryExecutor dml . onMessage Query.queryWithoutCacheLazyCheck ( GridMapQueryExecutor Query .java: 214 114 ) at org. apache h2 . ignite command . internal dml . processors Query .query (Query . java:352) at org. h2. twostep command . GridReduceQueryExecutor$1 dml . applyx Query.query ( GridReduceQueryExecutor Query .java: 154 333 ) at org. apache h2 . ignite command . internal CommandContainer . processors. query (CommandContainer . java:113) at org. h2. twostep command . GridReduceQueryExecutor$1 Command . applyx executeQuery ( GridReduceQueryExecutor Command .java: 152 201 ) at org. apache h2 . ignite jdbc . internal JdbcPreparedStatement . util.lang.IgniteInClosure2X.apply executeQuery ( IgniteInClosure2X JdbcPreparedStatement .java: 38 111 ) at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing. send executeSqlQuery (IgniteH2Indexing.java: 2555 1081 ) at org . apache . ignite . internal 56 more Caused by: java . processors lang . query NumberFormatException: For input string: "Front Door" at java . h2 lang . twostep NumberFormatException . GridReduceQueryExecutor forInputString(NumberFormatException . send java:65) at java.lang.Integer.parseInt ( GridReduceQueryExecutor Integer .java: 1419 580 ) at org java . apache lang . ignite Byte . internal parseByte(Byte . processors java:149) at java . query lang . Byte.parseByte(Byte.java:175) at org. h2. twostep value . GridReduceQueryExecutor Value . query convertTo ( GridReduceQueryExecutor Value .java: 732 936 ) ... 45 73 more{code}
This happens because actual parameter values are passed in wrong order, not 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. |
|