我在Java中使用了Goolgetifiy的Goolge Cloud Endpoints 我正面临这个错误。
引起:com.fasterxml.jackson.databind.JsonMappingException:直接自引用导致循环(通过引用链:org.octabyte.zeem1.Datastore.Comment [“postKey”] - > com.googlecode.objectify .KEY [ “根”])
这是实体评论:
@Id private Long commentId;
@Parent private Key<Post> postKey;
@Load private Ref<User> userRef;
// other code....
这是我的终点功能:
Key<Post> postKeyWithParent = Key.create(postSafeKey);
Key<Post> postKeyWithoutParent = Key.create(Post.class, postKeyWithParent.getId());
// Create user ref.
Ref<User> userRef = Ref.create(Key.create(User.class, userId));
// Create new instance of comment
Comment commentInstance = new Comment(
postKeyWithoutParent,
userRef);
ofy().save().entity(commentInstance).now();
// other code,