Updating a json field in PostgreSQL DB using Hibernate-Types returns InvalidDataAccessApiUsageException
See original GitHub issueHello Mr. @vladmihalcea , I hope that you’re safe and doing great.
Please, I’m facing some kind of exception with one of my applications.
I’m having this Class called Action :
This class has it’s own repository. At first I used to fetch and read the data from the DB with nor problems, I can read and use all the class attributes with no problems, the List<Upload>
too.
This is my Upload class :
At some point, the need to update the list of objects of my json was there, and I tried to add other objects to my List<Upload>
and updates it in my DB. But whatever I try to do, I’m always getting this Exception 😕
org.springframework.dao.InvalidDataAccessApiUsageException: Cannot create TypeBindings for class package_name.THE_CALLING_SERVICE$1 with 1 type parameter: class expects 0; nested exception is java.lang.IllegalArgumentException: Cannot create TypeBindings for class package_name.THE_CALLING_SERVICE$1 with 1 type parameter: class expects 0
PS: I’ve tried to keep the same code, commented the updatable attribute in @Column(... updatable = false)
, and the program executes normally, with no exception.
Could you point me out what I might be doing wrong here please.
Thanks in advance. Thank you for all what you do to the community ! Be safe and have a wonderful day 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
The collection handling was optimized in 2.x, so the 1.x mechanism was dropped. I’m glad you found a solution.
Ah okey, I see what you mean now my friend. I’ll try to do that very soon and I’ll post the results here.
If I can describe the problem shortly, it’s regarding the mapping of a List of objects as json array and store it in the database. I’ve tried to follow some of your article like this one (newer version) https://vladmihalcea.com/how-to-map-json-collections-using-jpa-and-hibernate/ but with no chance, else thing I’ve found another article kinda same but slightly different (older version) https://www.javaadvent.com/2017/12/map-json-collections-using-jpa-hibernate.html. I’ve noticed in the older version of Hibernate-types (52 - v1.2.0) you used the interface
TypeReferenceFactory
to deal with Lists and Maps … , that interface is not available in the latest version of Hibernate-types (52 - v2.9.x) I believe.Anyway, I solved the issue by implementing my own converter for the time being (if any one else came across this problem, this is the solution that worked for me quickly).
If you don’t mind I’m closing this issue for the time being since I solved the problem for the time being , once I’ll get my test case done, I’ll reopen it this and post here.
Thanks a lot @vladmihalcea , really appreciate your quick feedbacks !
Best of luck my friend !