FasterXML / FasterXML/jackson-datatype-hibernate

FORCE_LAZY_LOADING can cause useless session if FetchMode is set to JOIN

Open
#128 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
331
Forks
108
Avg merge
5h 3m
Merged PRs (30d)
1

Description

I have an `ElementCollection` on my object that is defaulting to lazy loading, but in my `Criteria` I've set the `FetchMode` to `Join`, which initializes the collection. While this causes the initialization of the collection to be identical to `FetchType.Eager` on the collection itself, it's marked at using lazy loading and therefore falls into the code linked here:
https://github.com/FasterXML/jackson-datatype-hibernate/blob/7ae60e9d2001639a2fa1e6df44c212bc74482b00/hibernate5/src/main/java/com/fasterxml/jackson/datatype/hibernate5/PersistentCollectionSerializer.java#L287-L295

I think getting to this point is fine, but shouldn't it be checked that `!coll.wasInitialized()` on line 290, prior to opening a temporary session that will essentially do nothing since the collection is already initialized?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.