I posted the annotation above the / pojo class and also set up mapper but still serialize null
I am using Hibernate 4.3.7Final and Jackson 2.4.4. Collections are lazy loaded
Pojo: Removed getters and setters
@JsonInclude(Include.NON_NULL) @Entity @Table public class School { @Id @GeneratedValue private int id; @OneToMany(cascade=CascadeType.ALL,fetch= FetchType.LAZY) private List<Student> students; @OneToMany(cascade=CascadeType.ALL,fetch= FetchType.LAZY) private List<Employee> staff; }
JSONMapper:
@Component public class JSONMapper extends ObjectMapper { private static final long serialVersionUID = -3131980955975958812L;
Exit:
{"id":1,"students":null,"staff":null}
java json spring jackson hibernate
Pushpendra jaiswal
source share