我必须在IN子句中添加一个字符串数组。
我的hibernate查询看起来像这样,
Query q =
session.createQuery("from CsePrcsngGroup where CSE_SID=? and CSE_GROUP IN(:cseGrpLists)");
q.setParameter(0, cseSid);
q.setParameterList("cseGrpLists", cseGrpLists);
return q.list();
其中CsePrcsngGroup是我的实体类。 CSE_SID和CSE_GROUP是字段名称,cseGrpLists是字符串数组。
我在执行时得到了这个消息,
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:185)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:503)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:535)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1849)
at org.hibernate.loader.Loader.doQuery(Loader.java:718)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.doList(Loader.java:2294)
... 55 more
Wrapped exception:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2297)
有什么建议吗?我尝试使用实体名称安装数据库列名但获得相同的错误。引用者:java.sql.SQLException:ORA-00942:表或视图不存在
答案 0 :(得分:0)
在查询中使用属性名称而不是列名。
Query q = session.createQuery("from CsePrcsngGroup where property1=? and property2 IN(:cseGrpLists)");
而不是'CSE_SID'
使用映射到此列(ex: id)