When trying to save an object in the database, it gives the following exception:
org.hibernate.exception.DataException: could not update. [...] Caused by: java.sql.SQLException: Operand type clash: image is incompatible with numeric.
I got the query run by Hibernate to do directly in the database. I put in it the same values that were being given in the code. Only the date (which in code is assigned with Calendar.getInstance()
) I did not write, putting a GETDATE()
. It worked! If all the fields I wrote the same, only the date that was obtained otherwise, I believe the problem is on the date. Even more by 'org.hibernate.exception.DataException'.
Now, I do not understand why. The field type in the database is datetime
. In JPA, in the code, it is as @Temporal(TemporalType.TIMESTAMP)
. Calendar.getInstance()
should not be a problem then.
Furthermore, you still have this
'Operand type clash: image is incompatible with numeric'.
Is it like he's accusing me of putting something of an image into the object? What's more, it says it's incompatible with numeric? But the field is dated. And the other fields should be ok as it worked when I query with the same values straight into the database.
UPDATED:
The query that is generated by hibernate:
update TABELA
set DATA_ALTERACAO_D= ?,
LOGIN_USUARIO_T= ?,
FK_TABELA2 = ?,
IND_T= ?,
LOGIN_USUARIO_ALT_T= ?,
NUM_A = ?,
NUM_U = ?,
FK_TABELA2 = ?,
S = ?
where ID = ?
I placed the query directly in the database, with the same values that would be received placed in the query in the application, replacing only the date (which in the application was Calendar.getInstance()
) and put GETDATE()
of SQL.
ex:
update TABELA
set DATA_ALTERACAO_D= GETDATE(),
LOGIN_USUARIO_T= '8888888',
FK_TABELA2 = '123123123123',
IND_T= 'I',
LOGIN_USUARIO_ALT_T= '8888888',
NUM_A = '654654',
NUM_U = '456456',
FK_TABELA2 = '38383838',
S = '1'
where ID = '7777777777'
There it worked. That is, the problem must be in the date field. But I can not understand how date relates to this error message.