Skip to content

Commit c37e0ff

Browse files
committed
Fix #36 for 2.2.4 (assuming it completely resolves the prob)
1 parent ab631b7 commit c37e0ff

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public void serializeWithType(Object value, JsonGenerator jgen, SerializerProvid
135135
protected boolean usesLazyLoading(BeanProperty property)
136136
{
137137
if (property != null) {
138+
// As per [Issue#36]
139+
ElementCollection ec = property.getAnnotation(ElementCollection.class);
140+
if (ec != null) {
141+
return (ec.fetch() == FetchType.LAZY);
142+
}
138143
OneToMany ann1 = property.getAnnotation(OneToMany.class);
139144
if (ann1 != null) {
140145
return (ann1.fetch() == FetchType.LAZY);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
import java.io.IOException;
44

5-
import javax.persistence.FetchType;
6-
import javax.persistence.ManyToMany;
7-
import javax.persistence.ManyToOne;
8-
import javax.persistence.OneToMany;
9-
import javax.persistence.OneToOne;
5+
import javax.persistence.*;
106

117
import org.hibernate.collection.spi.PersistentCollection;
128

13-
149
import com.fasterxml.jackson.core.*;
1510

1611
import com.fasterxml.jackson.databind.*;
@@ -141,6 +136,11 @@ public void serializeWithType(Object value, JsonGenerator jgen, SerializerProvid
141136
protected boolean usesLazyLoading(BeanProperty property)
142137
{
143138
if (property != null) {
139+
// As per [Issue#36]
140+
ElementCollection ec = property.getAnnotation(ElementCollection.class);
141+
if (ec != null) {
142+
return (ec.fetch() == FetchType.LAZY);
143+
}
144144
OneToMany ann1 = property.getAnnotation(OneToMany.class);
145145
if (ann1 != null) {
146146
return (ann1.fetch() == FetchType.LAZY);

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Jackson module to support datatypes of Hibernate 3.6 / 4.x, based on Jackson 2.x
33

44
Version: 2.2.4 (xx-xxx-2013)
55

6+
#36: Support `@ElementCollection` for specifying lazy-loading
67
#44: NullPointerException when @OneToMany map is encountered
78
(reported by Patrick H)
89

0 commit comments

Comments
 (0)