Skip to content

Commit b2548c4

Browse files
committed
Merge #140 fix to other backends, update release notes
1 parent 6b1bb45 commit b2548c4

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

hibernate4/src/main/java/com/fasterxml/jackson/datatype/hibernate4/Hibernate4Module.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.fasterxml.jackson.core.Version;
44
import com.fasterxml.jackson.databind.AnnotationIntrospector;
5-
import com.fasterxml.jackson.databind.Module;
65
import org.hibernate.SessionFactory;
76
import org.hibernate.engine.spi.Mapping;
87

hibernate5-jakarta/src/main/java/com/fasterxml/jackson/datatype/hibernate5/jakarta/PersistentCollectionSerializer.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,28 +343,29 @@ private void initializeCollection(PersistentCollection coll, Session session) {
343343
*/
344344
protected boolean usesLazyLoading(BeanProperty property) {
345345
if (property != null) {
346-
// As per [Issue#36]
346+
final boolean replaceCollection = Hibernate5JakartaModule.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
347+
// As per [datatype-hibernate#36]
347348
ElementCollection ec = property.getAnnotation(ElementCollection.class);
348349
if (ec != null) {
349-
return (ec.fetch() == FetchType.LAZY);
350+
return replaceCollection || (ec.fetch() == FetchType.LAZY);
350351
}
351352
OneToMany ann1 = property.getAnnotation(OneToMany.class);
352353
if (ann1 != null) {
353-
return (ann1.fetch() == FetchType.LAZY);
354+
return replaceCollection || (ann1.fetch() == FetchType.LAZY);
354355
}
355356
OneToOne ann2 = property.getAnnotation(OneToOne.class);
356357
if (ann2 != null) {
357-
return (ann2.fetch() == FetchType.LAZY);
358+
return replaceCollection || (ann2.fetch() == FetchType.LAZY);
358359
}
359360
ManyToOne ann3 = property.getAnnotation(ManyToOne.class);
360361
if (ann3 != null) {
361-
return (ann3.fetch() == FetchType.LAZY);
362+
return replaceCollection || (ann3.fetch() == FetchType.LAZY);
362363
}
363364
ManyToMany ann4 = property.getAnnotation(ManyToMany.class);
364365
if (ann4 != null) {
365-
return (ann4.fetch() == FetchType.LAZY);
366+
return replaceCollection || (ann4.fetch() == FetchType.LAZY);
366367
}
367-
// As per [Issue#53]
368+
// As per [datatype-hibernate#53]
368369
return !Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
369370
}
370371
return false;

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,28 +342,29 @@ private void initializeCollection(PersistentCollection coll, Session session) {
342342
*/
343343
protected boolean usesLazyLoading(BeanProperty property) {
344344
if (property != null) {
345-
// As per [Issue#36]
345+
final boolean replaceCollection = Hibernate5Module.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
346+
// As per [datatype-hibernate#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
}
366-
// As per [Issue#53]
367+
// As per [datatype-hibernate#53]
367368
return !Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
368369
}
369370
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ private void initializeCollection(PersistentCollection coll, Session session) {
343343
protected boolean usesLazyLoading(BeanProperty property) {
344344
if (property != null) {
345345
boolean replaceCollection = Hibernate6Module.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
346-
// As per [Issue#36]
346+
// As per [datatype-hibernate#36]
347347
ElementCollection ec = property.getAnnotation(ElementCollection.class);
348348
if (ec != null) {
349349
return replaceCollection || (ec.fetch() == FetchType.LAZY);
@@ -364,7 +364,7 @@ protected boolean usesLazyLoading(BeanProperty property) {
364364
if (ann4 != null) {
365365
return replaceCollection || (ann4.fetch() == FetchType.LAZY);
366366
}
367-
// As per [Issue#53]
367+
// As per [datatype-hibernate#53]
368368
return !Hibernate6Module.Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
369369
}
370370
return false;

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Project: jackson-datatype-hibernate
66

77
2.16.0 (not yet released)
88

9+
#140: `HibernateModule.REPLACE_PERSISTENT_COLLECTIONS` not working
10+
when `FetchType.EAGER`
911
- Hibernate deps:
1012
* 4.x: 4.1.12 -> 4.3.11
1113
* 5.x/JAXB: 5.3.28 -> 5.3.29

0 commit comments

Comments
 (0)