2

Oracleのストアドプロシージャにブールパラメータを渡すことができません。クエリテキスト(mypackage.Test(?, false、?、?);)に直接値を設定すると、すべて正常に機能します...

  • jdbc-ドライバー:ojdbc6.jar
  • コンテナ:Tomcat 7.0.28
  • hibernate-core + hibernate-entitymanager:4.1.6。最終
  • oracle:OracleDatabase11gリリース11.2.0.2.0-64ビット本番

ここに私の認識:

EntityManager em = defaultFactory.createEntityManager();
em.createNativeQuery("BEGIN mypackage.Test(?, ?, ?, ?); END;")//
    .setParameter(1, factId)//
    .setParameter(2, false)//
    .setParameter(3, auth.getDt())//
    .setParameter(4, auth.getName())//
.executeUpdate();

私の永続性-ユニット:

<persistence-unit name="unit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <non-jta-data-source>java:/comp/env/jdbc/db</non-jta-data-source>
        <properties>
        <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/> 
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> 
        <property name="hibernate.hbm2ddl.auto" value="validate" /> 
        <property name="hibernate.connection.characterEncoding" value="UTF-8" /> 
        <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
    </properties>
</persistence-unit>

ログ:

2013-01-24 11:28:44,582 DEBUG JdbcTransaction (71) - disabling autocommit
 2013-01-24 11:28:44,633 TRACE QueryPlanCache (196) - Unable to locate native-sql query plan in cache; generating (BEGIN 2013-01-24 11:28:44,582 DEBUG JdbcTransaction (71) - disabling autocommit
 2013-01-24 11:28:44,633 TRACE QueryPlanCache (196) - Unable to locate native-sql query plan in cache; generating (BEGIN mypackage.Test(?, ?, ?, ?); END;)
 2013-01-24 11:28:44,644 TRACE SQLCustomQuery (85) - Starting processing of sql query [BEGIN Collection_Fact_IUD.Del(?, ?, ?, ?); END;]
 2013-01-24 11:28:44,669 TRACE ConnectionProxyHandler (110) - Handling invocation of connection method [prepareStatement]
 2013-01-24 11:28:44,669 DEBUG SqlStatementLogger (104) - BEGIN mypackage.Test(?, ?, ?, ?); END;
 2013-01-24 11:28:44,670 TRACE JdbcResourceRegistryImpl (65) - Registering statement [org.hibernate.engine.jdbc.internal.proxy.PreparedStatementProxyHandler@41801d[valid=true]]
 2013-01-24 11:28:44,670 TRACE BasicBinder (83) - binding parameter [1] as [BIGINT] - 68593
 2013-01-24 11:28:44,670 TRACE AbstractStatementProxyHandler (88) - Handling invocation of statement method [setLong]
 2013-01-24 11:28:44,670 TRACE PreparedStatementProxyHandler (75) - Binding via setLong: [1, 68593]
 2013-01-24 11:28:44,672 TRACE BasicBinder (83) - binding parameter [2] as [BIT] - false
 2013-01-24 11:28:44,673 TRACE AbstractStatementProxyHandler (88) - Handling invocation of statement method [setBoolean]
 2013-01-24 11:28:44,673 TRACE PreparedStatementProxyHandler (75) - Binding via setBoolean: [2, false]
 2013-01-24 11:28:44,673 TRACE BasicBinder (83) - binding parameter [3] as [TIMESTAMP] - 2013-01-24 11:28:44.631
 2013-01-24 11:28:44,673 TRACE AbstractStatementProxyHandler (88) - Handling invocation of statement method [setTimestamp]
 2013-01-24 11:28:44,673 TRACE PreparedStatementProxyHandler (75) - Binding via setTimestamp: [3, 2013-01-24 11:28:44.631]
 2013-01-24 11:28:44,674 TRACE BasicBinder (83) - binding parameter [4] as [VARCHAR] - unknown
 2013-01-24 11:28:44,674 TRACE AbstractStatementProxyHandler (88) - Handling invocation of statement method [setString]
 2013-01-24 11:28:44,674 TRACE PreparedStatementProxyHandler (75) - Binding via setString: [4, unknown]
 2013-01-24 11:28:44,675 TRACE AbstractStatementProxyHandler (88) - Handling invocation of statement method [executeUpdate]
 2013-01-24 11:28:44,691 DEBUG SqlExceptionHelper (139) - ORA-06550: Строка 1, столбец 7:
PLS-00306: ошибочно число или типы аргументов при обращении к 'Test'
ORA-06550: Строка 1, столбец 7:
PL/SQL: Statement ignored
 [n/a]
 java.sql.SQLException: ORA-06550: Строка 1, столбец 7:
PLS-00306: ошибочно число или типы аргументов при обращении к 'Test'
ORA-06550: Строка 1, столбец 7:
PL/SQL: Statement ignored

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
    at ...

私の認識の何が問題になっていますか?

ありがとう!

4

0 に答える 0