question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating a json field in PostgreSQL DB using Hibernate-Types returns InvalidDataAccessApiUsageException

See original GitHub issue

Hello 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 : Class

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 : Class 2

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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
vladmihalceacommented, May 12, 2020

The collection handling was optimized in 2.x, so the 1.x mechanism was dropped. I’m glad you found a solution.

0reactions
NA-Jaliliuscommented, May 12, 2020

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 !

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to update a JSONB column in PostgreSQL using a ...
ERROR: column "itemsinventory_addtion_details" is of type jsonb but expression is ... First, you need to add the Hibernate Types dependency:
Read more >
How to use PostgreSQL's JSONB data type with Hibernate
One example is PostgreSQL's JSONB data type which allows you to store JSON documents efficiently in a database column. You could, of course,...
Read more >
Common Hibernate Exceptions - Baeldung
Many conditions can cause exceptions to be thrown while using Hibernate. These can be mapping errors, infrastructure problems, SQL errors, ...
Read more >
Spring Data R2DBC - Reference Documentation
You can use the types in the first column (or subtypes thereof) as query method return types and get the types in the...
Read more >
[Solved]-Correct value of a json data saved using JPA, spring ...
Coding example for the question Correct value of a json data saved using JPA, spring and kotlin Map -postgresql.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found