Skip to content

Commit

Permalink
fix REPLACE_PERSISTENT_COLLECTIONS in EAGER
Browse files Browse the repository at this point in the history
  • Loading branch information
pses authored Dec 1, 2021
1 parent 22706d6 commit 515f8d1
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,29 +342,31 @@ private void initializeCollection(PersistentCollection coll, Session session) {
*/
protected boolean usesLazyLoading(BeanProperty property) {
if (property != null) {

boolean replaceCollection = Hibernate5Module.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 !Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
return !Hibernate5Module.Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
}
return false;
}
Expand Down

0 comments on commit 515f8d1

Please sign in to comment.