Skip to content

Commit 6b1bb45

Browse files
authored
Update PersistentCollectionSerializer.java (#173)
fix REPLACE_PERSISTENT_COLLECTIONS in EAGER #146
1 parent 59191e6 commit 6b1bb45

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

hibernate6/src/main/java/com/fasterxml/jackson/datatype/hibernate6/PersistentCollectionSerializer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,26 +342,27 @@ private void initializeCollection(PersistentCollection coll, Session session) {
342342
*/
343343
protected boolean usesLazyLoading(BeanProperty property) {
344344
if (property != null) {
345+
boolean replaceCollection = Hibernate6Module.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
345346
// As per [Issue#36]
346347
ElementCollection ec = property.getAnnotation(ElementCollection.class);
347348
if (ec != null) {
348-
return (ec.fetch() == FetchType.LAZY);
349+
return replaceCollection || (ec.fetch() == FetchType.LAZY);
349350
}
350351
OneToMany ann1 = property.getAnnotation(OneToMany.class);
351352
if (ann1 != null) {
352-
return (ann1.fetch() == FetchType.LAZY);
353+
return replaceCollection || (ann1.fetch() == FetchType.LAZY);
353354
}
354355
OneToOne ann2 = property.getAnnotation(OneToOne.class);
355356
if (ann2 != null) {
356-
return (ann2.fetch() == FetchType.LAZY);
357+
return replaceCollection || (ann2.fetch() == FetchType.LAZY);
357358
}
358359
ManyToOne ann3 = property.getAnnotation(ManyToOne.class);
359360
if (ann3 != null) {
360-
return (ann3.fetch() == FetchType.LAZY);
361+
return replaceCollection || (ann3.fetch() == FetchType.LAZY);
361362
}
362363
ManyToMany ann4 = property.getAnnotation(ManyToMany.class);
363364
if (ann4 != null) {
364-
return (ann4.fetch() == FetchType.LAZY);
365+
return replaceCollection || (ann4.fetch() == FetchType.LAZY);
365366
}
366367
// As per [Issue#53]
367368
return !Hibernate6Module.Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);

0 commit comments

Comments
 (0)