我正在使用休眠版本4.3.11.Final和1.0.0.Final。 hibernate.dilect = org.hibernate.dialect.Oracle12cDialectsetMaxResults(max_size)拋出Sql命令沒有正常結束異常
final String hql1 = "select s from " + app.class.getSimpleName() + " s where s.Id = " + getId();
When i'm calling
mEntityManager.createQuery(hql1, app.class).setMaxResults(3);
生成HQL = 「從test.APP_TABLE選擇app_.ID作爲ID6_157_ APP_其中app_.ID = 83700取第一?行僅」
似乎是'?'的問題沒有被setMaxResults的值3替換,但無法弄清楚如何解決它。 它拋出異常: -
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884)
oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80)
org.hibernate.loader.Loader.getResultSet(Loader.java:2065)
org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
org.hibernate.loader.Loader.doQuery(Loader.java:909)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
org.hibernate.loader.Loader.doList(Loader.java:2553)
org.hibernate.loader.Loader.doList(Loader.java:2539)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
org.hibernate.loader.Loader.list(Loader.java:2364)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
查詢工作正常,如果我從的createQuery刪除setMaxResults(3)。
任何建議可能是這個原因。
從test.APP_TABLE app_中選擇app_.ID作爲ID6_157_,其中app_.ID = 83700首先獲取?只有行 –
此查詢與JPA無關。爲何使用錯誤的標籤? – ujulu