java - JPA TypedQuery: Parameter value element did not match expected type -
I am using JPA 2.0 and getting the following code in the DAO layer:
Public Zero Test () {string key = "status"; String [] Conditions = {"A", "B"}; & Lt; TestTable & gt; Results = Search (Keys, Conditions); } Public listing & lt; TestTable & gt; Search (string key, object value error) {string sql = "test ndf to testlet and jade nand." + Key + "in:" + key; TypedQuery & LT; TestTable & gt; Query = entityManager.createQuery (SQL, TestTable.class); Query.setParameter (key, Arrays.asList (valueArr)) / *** Error Line *** Return query.getResultList (); } In the above error line, it throws the following exception:
java.lang.IllegalArgumentException: parameter value element [[Ljava.lang.String; @ cbe5bc] did not match the expected type [java.lang.String] Why is this expected type string while actually this string []? Please help!
Note: This is derived from the normal routine and is a simplified code. I can not convert the 'object valueRR' into a string because it is being used for other people ...
You've got a type of variable object , and you're calling it means that you Effectively called: list & lt; Object & gt; Value = array.select (new object [] {valueArr}); So you are making a list of elements where the element is an array. It's not what you want ... you want a list & lt; Object & gt; The easiest way to do this is to change your parameter type: public list & lt; TestTable & gt; Search (string key, object [] value) ... query.setParameter (key, arrays.asList (values));
Comments
Post a Comment