Tags
Authors
In our previous post,
we showed how @Mutability(Immutability.class) and removing CascadeType.MERGE cut our JSON processing time in half by eliminating unnecessary dirty-checking.
That was the first round of optimization. This post covers the second round enabling Hibernate’s second-level cache on the same entity, and the surprising
discovery that three annotations must work together to unlock the full benefit. Getting two out of three still left us over 8x slower than the final result.
When we profiled our application’s data import pipeline, we expected the bottleneck to be in our business logic — JQ filters, JavaScript evaluation, recursive SQL queries. Instead, Hibernate’s internal JSON handling consumed over 50% of CPU time and allocated 20 GB of unnecessary objects during a routine import of 5 records.
Two small annotation changes fixed it. No code changes, no architectural redesign — just telling Hibernate what it needs to know about how our application uses its data.