i trying implement jsonview selectively serialize fields entity json serialized has empty objects no fields. below code:
viewclass:
public class auditreportview { public interface summary {} }
entity:
@entity @sequencegenerator(name = "audit_report_sequence_generator", sequencename = "ejb_audit_report_seq", initialvalue = 1, allocationsize = 1) @table(name = "device_audit_report") @data public class auditreport implements serializable { private static final long serialversionuid = 1246376778314918671l; @id @generatedvalue(strategy = generationtype.sequence, generator = "audit_report_sequence_generator") @column(name = "id", nullable = false) @jsonview(auditreportview.summary.class) private long id; @column(name = "device_id", nullable = false) @jsonview(auditreportview.summary.class) private string deviceid; @column(name = "report_timestamp", nullable = false) @jsonview(auditreportview.summary.class) private calendar reporttimestamp; @column(name = "user_id", nullable = false) @jsonview(auditreportview.summary.class) private long userid; @column(name = "username", nullable = false) @jsonview(auditreportview.summary.class) private string username; @column(name = "start_date", nullable = false) @jsonview(auditreportview.summary.class) private calendar startdate; @column(name = "end_date", nullable = false) @jsonview(auditreportview.summary.class) private calendar enddate; @onetomany(mappedby = "auditreport", fetch = fetchtype.lazy, orphanremoval = true, cascade={cascadetype.all}) private set<auditentry> auditentries = new hashset<auditentry>(); }
controller:
@jsonview(auditreportview.summary.class) @requestmapping(method = requestmethod.get, value = "auditreportsummary") public @responsebody responseentity<?> getauditreportsummary() { final list<auditreport> auditreports = auditdao.getauditreportsummary(); return new responseentity<>(auditreports, httpstatus.ok); }
json postman:
[ {}, {}, {} ]
the database has 3 results , when debug definately pulling them out, no members being serialized. i'm using spring 4.3.7 , jackson 2.8.7. ideas of wrong or start debugging issue?
thanks
Comments
Post a Comment