Hi,
I am using the JPA provided by Hibernate 3.2.4. I am trying to call a stored procedure with a numeric parameter where the value of the parameter is null.
Java code (both properties are java.lang.Long):
entityManager.createNamedQuery("insertVsAPRecord")
.setParameter(1, data.getId())
.setParameter(2, data.getSubsRefNum())
.executeUpdate();
Hibernate mapping:
<hibernate-mapping package="nl.tele2.agent.ixi.domain">
<sql-query name="insertVsAPRecord" callable="false">
{ call pck.ins_record(?, ?) }
</sql-query>
</hibernate-mapping>
Oracle package pck:
PROCEDURE ins_record (
p_payload_id IN NUMBER(10)
, p_subsrefnum IN NUMBER(10)
);
When I call the stored procedure with values for the properties in the data object, it works fine. When one or both properties are null, it fails with an Oracle error:
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:59)
at nl.tele2.agent.ixi.IxiReceiver.insertIxiData(IxiReceiver.java:226)
... 20 more
Caused by: org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:50)
... 21 more
Caused by: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INS_RECORD'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
When I use the Hibernate Session and execute with the same data it works.
Java code with Hibernate session:
hibernateSession.getNamedQuery("insertVsAPRecord")
.setParameter(0, data.getId())
.setParameter(1, data.getSubsRefNum(), new LongType())
.executeUpdate();
Is this a bug in the JPA implementation by Hibernate?
If not, is there any way this can be done in JPA?
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.2.4
Mapping documents:Java 5 JPA
Name and version of the database you are using:Oracle 9i