Row is always updated when using JSON objects wrapped in POJOs with no explicit equals method
See original GitHub issueHello,
I am using PostgreSQL database and have a table with some jsonb data. I am using JsonBinaryType from hibernate-types-52 to map jsonb to POJO property in my entity.
@Entity
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
public class InstrumentEntity{
....
@Type(type = "jsonb")
@Column(name = "instrument_configuration", columnDefinition = "jsonb")
private InstrumentConfiguration configuration;
....
}
My problem is the following, even when I am only trying to fetch (read) the entity from the database and don’t update anything in it, when my transaction finishes, hibernate performs a row update! I know this because I see it in PostgreSQL log. This is really unexpected and causes performance regression and even deadlocks in my application.
How to avoid performing row updates when I only want to fetch the data? If no JsonBinaryType is used, row is only updated if I update the entity, as expected.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:17 (10 by maintainers)
Top Results From Across the Web
Jackson: How to add custom property to the JSON without ...
Simply wrap the POJO in a MorphedResult, and then add or remove properties at will. When serialized, the MorphedResult wrapper disappears and any...
Read more >Hibernate ORM 5.4.33.Final User Guide - Red Hat on GitHub
Hibernate not only takes care of the mapping from Java classes to database ... while the wrap method is used to transform the...
Read more >POJO Data Binding Interface (Java Application Developer's ...
The Data Bind interface is intended for use in situations where the in-database representation of objects is not as important as using a...
Read more >JSONObject - Android Developers
Creates a new JSONObject with name/value mappings from the JSON string. ... If the object is a JSONArray or JSONObject , no wrapping...
Read more >ItemReaders and ItemWriters - Spring
An item might represent a line in a file, a row in a database, or an element ... Spring Batch begins the process...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I managed to replicate it and this commit fixes the issue. This fix will be included in 2.9.7, but I will wait for one or two more fixes or improvements to release that.
You should give it a try and see if it works for you too. You can build the
hibernate-types-52
without running the tests and use the2.9.7-SNAPSHOT
artifact to validate the fix.I’m glad I could help