سؤال

I'm working on a web application using Spring REST (3.2.8.RELEASE), GAE and Objectify (v 4.0b3). I'm new to both GAE and Objectify.

The application returns data in JSON format.

I'm getting a 500 error when Jackson serializes the Objectify Key. So, I tried to use @JsonIgnore as mentioned in this posting JsonMappingException: How to transfert a Objectify Entity (with Key) through Restlet . But it's still throwing the same 500 error. I tried to place the @JsonIgnore at the attribute, getter, setter method, but no luck.

Can someone give me some guidance on what I may be doing incorrectly? The other option is to write a custom serializer.

Thanks so much in advance for your help.

public class CategoryTrackingCount {

    Key<CategoryTracking> categoryTrackingKey;

    @JsonIgnore     
    public Key<CategoryTracking> getCategoryTrackingKey() {
        return categoryTrackingKey;
    }

    @JsonIgnore
    public void setCategoryTrackingKey(Key<CategoryTracking> categoryTrackingKey) {
        this.categoryTrackingKey = categoryTrackingKey;
    }
}
هل كانت مفيدة؟

المحلول

I don't know why Jackson is ignoring the @JsonIgnore (perhaps you are using the wrong version of the jackson annotation? Do you have Jackson v1 and Jackson v2 both on your classpath?) but Objectify includes a custom Jackson module:

https://code.google.com/p/objectify-appengine/source/browse/src/main/java/com/googlecode/objectify/util/jackson/ObjectifyJacksonModule.java

Also, 4.0b3 is ancient. Please upgrade.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top