Skip to content

Commit

Permalink
Merge #140 fix to other backends, update release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 6, 2023
1 parent 6b1bb45 commit b2548c4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.Module;
import org.hibernate.SessionFactory;
import org.hibernate.engine.spi.Mapping;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,28 +343,29 @@ private void initializeCollection(PersistentCollection coll, Session session) {
*/
protected boolean usesLazyLoading(BeanProperty property) {
if (property != null) {
// As per [Issue#36]
final boolean replaceCollection = Hibernate5JakartaModule.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
// As per [datatype-hibernate#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]
// As per [datatype-hibernate#53]
return !Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,28 +342,29 @@ private void initializeCollection(PersistentCollection coll, Session session) {
*/
protected boolean usesLazyLoading(BeanProperty property) {
if (property != null) {
// As per [Issue#36]
final boolean replaceCollection = Hibernate5Module.Feature.REPLACE_PERSISTENT_COLLECTIONS.enabledIn(_features);
// As per [datatype-hibernate#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]
// As per [datatype-hibernate#53]
return !Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ 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]
// As per [datatype-hibernate#36]
ElementCollection ec = property.getAnnotation(ElementCollection.class);
if (ec != null) {
return replaceCollection || (ec.fetch() == FetchType.LAZY);
Expand All @@ -364,7 +364,7 @@ protected boolean usesLazyLoading(BeanProperty property) {
if (ann4 != null) {
return replaceCollection || (ann4.fetch() == FetchType.LAZY);
}
// As per [Issue#53]
// As per [datatype-hibernate#53]
return !Hibernate6Module.Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
}
return false;
Expand Down
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Project: jackson-datatype-hibernate

2.16.0 (not yet released)

#140: `HibernateModule.REPLACE_PERSISTENT_COLLECTIONS` not working
when `FetchType.EAGER`
- Hibernate deps:
* 4.x: 4.1.12 -> 4.3.11
* 5.x/JAXB: 5.3.28 -> 5.3.29
Expand Down

0 comments on commit b2548c4

Please sign in to comment.