Error: 'Operand type Clash: image is incompatible with Numeric'

Asked

Viewed 76 times

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.

  • 1

    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?

  • I put the query.

  • 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.

1 answer

0

looks like it was because it was a field that was fk (so I didn’t just pass the ID, pass the whole object to this field fk) but jpa was set to common field (@Column) and not fk ( @Joincolumn). Being set up as a common field, he expected only a pure value (I think it would work if I passed only the pure id), but I passed an entire object, from which he should take the id and he should not understand. Then it would only work if the field was set to fk, with @Joincolumn.

I switched to @Joincolumn and it worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.