java - How to get jackson to ignore non-DTO objects -


we upgraded glassfish jersey 2.7 sun jersey implementation. when did jackson started trying deserilize our domain objects. in our case isn't want. have domain setup domain objects never directly sent out via web services. transformed in dto , sent out. call

return response.ok(new somefoobardtoobject(somefoobardomainobject)).build()

and use work previous version of jersey/jackson. more date code we're getting errors following:

conflicting setter definitions property "preferreditem": com.foo.domain.foobar#setpreferreditem(1 params) vs com.foo.domain.foobar#setpreferreditem(1 params)

even though never try send out actual domain object. how tell jackson @ objects received or sent via web service.

here web service causing issue i've simplified down this. if take out restaurantitemdto restaurantitemdto method parameters works, if keep in there doesn't.

restaurantitemdto has base types in it's fields. way references domain object through constructor parameter, , there public no parameter constructor well. it's not constructor.

@controller @path("/restaurant/restaurantitem") public class restaurantitemwebservice {     @put     @path("/ordersheets/{ordersheetid}/{locationid}/restaurantitems/{restaurantitemid}")     @produces(value = mediatype.application_json)     @consumes(value = mediatype.application_json)     @transactional     @preauthorize("hasrole('" + permissionnames.some_permission+ "')")     public response saveexistingrestaurantitem(@pathparam("ordersheetid") long ordersheetid, @pathparam("restaurantitemid") long restaurantitemid, restaurantitemdto restaurantitemdto) {         return response.ok(restaurantitemdto).build();     } 

well wasn't able figure out why jackson behaved way did, did find issue had constructor dto referenced domain object, , though jackson should have never called constructor since there default public parameterless constructor available, still tried map domain object. got around using @jsonignore on constructor referenced domain object.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -