I have the same problem when setting null parameter value for long, integer types. My simplified code is here
String createQuery = "INSERT INTO my_table(id, counter) VALUES( :id, :counter)";
Long id = 22L;
Integer counter = null;
Query query = em.createNativeQuery(createQuery);
query.setParam("id", id);
query.setParam("counter", counter);
query.executeUpdate();
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:49)
... 27 more
Caused by: java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:626)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:182)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:630)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1081)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2916)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2988)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
... 30 more
I tried the following combination without any success.
Hibernate 3.3.2.GA + Oracle JDBC Driver v10.1.0.4.2 / v11.2.0.3.0
Hibernate 3.2.6 + Oracle JDBC Driver v10.1.0.4.2 / v11.2.0.3.0
I cannot use Hibernate version above 3.3.2 due to incompability with GlassFish v2.1. Is there any patch or solution except generate dynamic query that excludes null parameters from the query?
I have the same problem when setting null parameter value for long, integer types. My simplified code is here
String createQuery = "INSERT INTO my_table(id, counter) VALUES( :id, :counter)";
Long id = 22L;
Integer counter = null;
Query query = em.createNativeQuery(createQuery);
query.setParam("id", id);
query.setParam("counter", counter);
query.executeUpdate();
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:49)
... 27 more
Caused by: java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:626)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:182)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:630)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1081)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2916)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2988)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
... 30 more
I tried the following combination without any success.
Hibernate 3.3.2.GA + Oracle JDBC Driver v10.1.0.4.2 / v11.2.0.3.0
Hibernate 3.2.6 + Oracle JDBC Driver v10.1.0.4.2 / v11.2.0.3.0
I cannot use Hibernate version above 3.3.2 due to incompability with GlassFish v2.1. Is there any patch or solution except generate dynamic query that excludes null parameters from the query?