java. sql. Sqlexception: ora-00932: inconsistent data type: expected number to get binary
•
Java
I have a method in Dao class that returns list < object [] > Back, I'm using named queries
public List<Object[]> getListByCustomer(Session session,int customerId,List<Integer> strIds) {
Query namedQuery = session.createsqlQuery(QueryConstants.EXPORT);
namedQuery.setParameter("customer",customerId);
namedQuery.setParameter("stringId",strIds);
List<Object[]> objects = namedQuery.list();
return objects;
}
I want to pass list < integer > and put the strid in stringid into the named query, as shown below:
public class QueryConstants {
public static final String EXPORT =
"SELECT sv.NAME,sv.TYPE,sv.CLIENT_ADDRESS,sv.NAME_REDUNDANT,sv.DEPARTURE_DATE,s1.CODE,sv.STATE,sv.CODE "
+ "FROM VIEW sv,PROCESS p1,SET s1 "
+ "WHERE sv.R_ID = p1.R_ID and p1.ISSUER_ID = s1.USER_ID and sv.CUSTOMER_ID = :customer and sv.R_ID IN (:stringId)";
}
But I got ora-00932: inconsistent data types: expected number to get binary
In addition, when I delete SV. Net from the query R_ When ID in (: stringid), it works normally. When I pass integer (strids) instead of list < integer > to enter the query, it works normally
I'm using Oracle 10g
Solution
I think you just need to use
IN :stringId
replace
IN (:stringId)
For JPA
namedQuery.setParameter("stringId",strIds);
Yes, but for hibernate, you should use
namedQuery.setParameterList("stringId",strIds);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
