jpa,hibernate版本支持createNativeQuery方法

时间:2017-06-15 13:55:22

标签: hibernate jpa ojdbc

我使用下面的罐子:

hibernate-entitymanager:jar:3.5.3-Final
hibernate-core:jar:3.5.3-Final
org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final
com.oracle:ojdbc6:jar:11.2.0.1.0

当我尝试执行createNativeQuery时,我面临异常:

Query q = em.createNativeQuery("SELECT B_ID, B_LAN FROM BOOK");
List<Object[]> books = q.getResultList();

例外:

select
       B_ID,
       B_LAN
 from
       BOOK

Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491) ~[ojdbc6-11.2.0.1.0.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:1112) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:714) ~[com.ibm.ws.runtime.jar:na]
    at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) ~[hibernate-core-3.5.3-Final.jar:3.5.3-Final]
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1849) ~[hibernate-core-3.5.3-Final.jar:3.5.3-Final]
    at org.hibernate.loader.Loader.doQuery(Loader.java:718) ~[hibernate-core-3.5.3-Final.jar:3.5.3-Final]
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270) ~[hibernate-core-3.5.3-Final.jar:3.5.3-Final]
    at org.hibernate.loader.Loader.doList(Loader.java:2294) ~[hibernate-core-3.5.3-Final.jar:3.5.3-Final]

问题:

这是因为我使用的jar版本不支持createNativeQuery方法吗?

哪个版本的hibernate-jpa jar支持createNativeQuery

0 个答案:

没有答案