0

I have a user -> hasMany userPermission, and am getting a circular reference when spring MVC tries to output JSON. If I set the user permissions to null, it works. If I have a user->hasmany->userpermission (and permission manyToOne user) I get a stack overflow.

User class has:

@OneToMany(mappedBy="user", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
    @JsonManagedReference("user-perm") private List<UserPermission> userPermissions;

UserPermissoin has: //bi-directional many-to-one association to User

@ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
    @JoinColumn(name="user_id", nullable=false)
    @JsonBackReference("user-perm") private User user;

Any ideas here?


* Update * Jackson 2.3.0 fixed it, Spring works with 2.3.0 from 1.9 with no config changes, just changing the maven dependencies.

Barranka
  • 20,547
  • 13
  • 65
  • 83
mikeb
  • 10,578
  • 7
  • 62
  • 120

1 Answers1

0

user1022260: Jackson 2.3.0 fixed it, Spring works with 2.3.0 from 1.9 with no config changes, just changing the maven dependencies.

MariuszS
  • 30,646
  • 12
  • 114
  • 155