0
When trying to save an object in the database, 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 took the query executed 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 the code is assigned with Calendar.getInstance()
) I didn’t write, putting a GETDATE()
. It worked! If all fields I wrote the same, only the date that was otherwise obtained, I believe the problem is in the date. Even more by 'org.hibernate.Exception.Dataexception'.
Now, I don’t understand why. The guy from the field at the bank is datetime
. In JPA, in the code, it’s like @Temporal(TemporalType.TIMESTAMP)
. The Calendar.getInstance()
shouldn’t be a problem then.
Besides, there’s still that
'Operand type Clash: image is incompatible with Numeric'.
Is it as if he was accusing that I put something of the image type in the object? On top of that, does he say that it is incompatible with numerical? But the field is date. And the other fields should be ok as it worked when I did the query with the same direct values in the bank.
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 the 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'
Then it worked. That is, the problem must be in the date field. But I can’t understand how date relates to this error message.
Two important things: 1. Try to use more succinct titles. 2. In org.hibernate.Exception.Dataexception Data is in English, it has nothing to do with date (time), but this does not mean that the problem is in another field. It has how to put the query generated by Hibernate in question?
– Jéf Bueno
I put the query.
– Cleber Farinazzo Junior
I really don’t understand the problem. I have looked, the debugging, the values that are in all attributes of the object and none is getting something like image.
– Cleber Farinazzo Junior