Skip to content

Commit

Permalink
Update PersistentCollectionSerializer.java (#173)
Browse files Browse the repository at this point in the history
fix REPLACE_PERSISTENT_COLLECTIONS in EAGER #146
  • Loading branch information
Taha-Di-Nero authored Jun 6, 2023
1 parent 59191e6 commit 6b1bb45
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,26 +342,27 @@ private void initializeCollection(PersistentCollection coll, Session session) {
*/
protected boolean usesLazyLoading(BeanProperty property) {
if (property != null) {
boolean replaceCollection = Hibernate6Module.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
// As per [Issue#36]
ElementCollection ec = property.getAnnotation(ElementCollection.class);
if (ec != null) {
return (ec.fetch() == FetchType.LAZY);
return replaceCollection || (ec.fetch() == FetchType.LAZY);
}
OneToMany ann1 = property.getAnnotation(OneToMany.class);
if (ann1 != null) {
return (ann1.fetch() == FetchType.LAZY);
return replaceCollection || (ann1.fetch() == FetchType.LAZY);
}
OneToOne ann2 = property.getAnnotation(OneToOne.class);
if (ann2 != null) {
return (ann2.fetch() == FetchType.LAZY);
return replaceCollection || (ann2.fetch() == FetchType.LAZY);
}
ManyToOne ann3 = property.getAnnotation(ManyToOne.class);
if (ann3 != null) {
return (ann3.fetch() == FetchType.LAZY);
return replaceCollection || (ann3.fetch() == FetchType.LAZY);
}
ManyToMany ann4 = property.getAnnotation(ManyToMany.class);
if (ann4 != null) {
return (ann4.fetch() == FetchType.LAZY);
return replaceCollection || (ann4.fetch() == FetchType.LAZY);
}
// As per [Issue#53]
return !Hibernate6Module.Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
Expand Down

0 comments on commit 6b1bb45

Please sign in to comment.