behavior - Hibernate ManyToOne and OneToMany -
i have relationship mapped example.
@entity @table(name = "shop") public class shop implements serializable { ... @onetomany(mappedby = "shop", fetch=fetchtype.lazy) private set<event> events; ... }
@entity @table(name = "event") public class event implements serializable { ... @manytoone(fetch = fetchtype.lazy) @joincolumn(name = "shop_id", nullable = false) private shop shop; ... }
when local getevent() called loaded in colletion 1 list few events, each event have inside shop might have inside event , successively.. ok?. can problem responsing json structure?
i had problem during serialization json
... @ org.codehaus.jackson.map.ser.std.collectionserializer.serializecontents(collectionserializer.java:72) @ org.codehaus.jackson.map.ser.std.collectionserializer.serializecontents(collectionserializer.java:23) @ org.codehaus.jackson.map.ser.std.asarrayserializerbase.serialize(asarrayserializerbase.java:86) @ org.codehaus.jackson.map.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:446) @ org.codehaus.jackson.map.ser.std.beanserializerbase.serializefields(beanserializerbase.java:150) @ org.codehaus.jackson.map.ser.beanserializer.serialize(beanserializer.java:112) @ org.codehaus.jackson.map.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:446) @ org.codehaus.jackson.map.ser.std.beanserializerbase.serializefields(beanserializerbase.java:150) @ org.codehaus.jackson.map.ser.beanserializer.serialize(beanserializer.java:112) ...
to solve used @jsonignore annotation in 1 property:
@entity @table(name = "shop") public class shop implements serializable { ... @jsonignore @onetomany(mappedby = "shop", fetch=fetchtype.lazy) private set<event> events; ... }
i hope information helpful. can't add comments yet.
Comments
Post a Comment