For some odd reason when I execute a mysql stored procedure via hibernate it interprets a string "N/A" as a double value and throws an error. When running the same query in mysql directly everything works fine, but Hibernate seems to think I'm trying to divide? If all things left the same "NA" the stored procedure runs with no problem via hibernate.

Any idea how to get the sting to be accepted in hibernate?

The call:

 def query = session.createSQLQuery("call myproc (:id, :date)")
                .setParameter("id", 168)
                .setParameter("date", "2015-02-01").executeUpdate()

The part of the stored procedure:

insert table1
      ( myvarchar255field)
        ( select "N/A"
          from table2
          where [something else happens]);

org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTy>peDelegate.java:69) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211) at org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:211) at org.hibernate.internal.SessionImpl.executeNativeUpdate(SessionImpl.java:1310) at org.hibernate.internal.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:389) at Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'N/A' at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3885) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2530) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1907) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2141) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2077) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2062) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208) ... 4 more

0

There are 0 best solutions below