When running an integration test, the following PSQLException error occurs:
The corresponding model hasString
Type fields are marked@ Lob
, Hibernate converts itCLob
.
HoweverCLob
EDB'sGetClob
Method calledGetLong
And then tryCLob
ConvertLong
.
No edb source code, so I had to find the pg source code on Github and find the method that caused this error.ToLong
, Which is consistent with my judgment.
(It is unwise to output errors in Chinese after localization. Searching for "wrong Long" may not be able to find anything at all, but searching for "bad value for type Long" is totally different .)
Why callGetLong
What about it?
In this article, we found that Large objects are stored in other locations and directly store their pointers (that is, a long Object ). If the type is text, the text is directly stored instead of the pointer, so the conversion fails.
It is worth noting that,CLob
The corresponding columns in PostgreSQL should not be text columns, so do not be misled.
The solution is simple. Delete it in the model.@ Lob
Annotation for Hibernate to callGetString
InsteadGetCLob
You can.
Or keep@ Lob
Annotation, and then add one@ Org. hibernate. annotations. Type (type = "org. hibernate. type. StringClobType ")
.