0

I'm getting this error when using Spring + JPA (Repositories) + Hibernate to update an existing record in a table.

2019-07-01 17:47:47.526  WARN o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 8114, SQLState: 37000
2019-07-01 17:47:47.527 ERROR o.h.engine.jdbc.spi.SqlExceptionHelper   : Error converting data type nvarchar to numeric.
2019-07-01 17:47:47.527 ERROR o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush
[org.hibernate.exception.SQLGrammarException: could not execute statement]
2019-07-01 17:47:47.562 ERROR c.a.p.controller.AdminClaimController    : July 1, 2019 5:47:47 PM PDT
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not execute statement

This update operation worked recently, but it isn't working now.

The Stackoverflow question is here
How am I supposed to know what column or data value this problem is related to?

End of Stackoverflow question being asked

Unfortunately, the table has 145 columns.
The error occurs when calling CrudRepository.save(Object myObject))

Since I am sure I would agree with them, please put your comments about how tables should be designed in a discussion forum somewhere else as that is obviously not what my question is about - thank you and I promise I will read them later! :D

xgord
  • 4,606
  • 6
  • 30
  • 51
user1445967
  • 1,520
  • 4
  • 14
  • 30
  • *Unfortunately, the table has 145 columns.* - That is maybe the starting point of your problem. But seriously without code, how could even guess? – Scary Wombat Jul 02 '19 at 00:56
  • I definitely would prefer information about how to get more details out of the exception, rather than a guess. Many thanks. – user1445967 Jul 02 '19 at 00:58
  • The error posted is not the entire Exception. You are not showing any code, but am I right in assuming that you have code log `ex.printStackTrace`, show the entire stacktrace. – Scary Wombat Jul 02 '19 at 01:01
  • Stack trace is provided but I am not 100% sure if this is what my question was about? Doesn't Hibernate have a way to tell you which `nvarchar` and which `numeric` it is talking about? – user1445967 Jul 02 '19 at 01:07
  • But surely you can understand the error? You are trying to store something in a column and the type does not match e.g. a String into a Number. Without code, what else can we say? – Scary Wombat Jul 02 '19 at 01:09
  • Question is about Hibernate / JPA not about my code. Thanks for your help. – user1445967 Jul 02 '19 at 01:12
  • On the Object that you are trying to commit, find all `String` types and double check again the DB? The question maybe about `Hibernate` but at the end of the day, it is about SQL. – Scary Wombat Jul 02 '19 at 01:14
  • see this answer, it may help you. https://stackoverflow.com/a/2536835/2310289 – Scary Wombat Jul 02 '19 at 01:16

1 Answers1

0

It appears that the answer is: This is not generally possible under SQL databases. You are supposed to look at all the data values you tried to update and figure out which one is inappropriate for its column. Perhaps a more advanced approach could be taken by changing the values one at a time, and seeing what change caused the error.

I think this is a ridiculous thing to have to do 19% of the way into the 21st century but apparently we still have a long way to go in order to come out of the dark ages of computing.

user1445967
  • 1,520
  • 4
  • 14
  • 30