クラスに複数のバックリファレンスクラスがあります。私は@JsonBackReference
を使用しているので、私はエラーが発生します。私はそれらのクラスの@JsonIdentityInfo
注釈を割り当てましたが、私はまだ同じエラーが発生します。名前が 'defaultReference'の複数のバックリファレンスプロパティ
public class X implements Serializable {
....
//bi-directional many-to-one association to Booking
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "xxA", nullable = false)
@JsonBackReference
private A a;
//bi-directional many-to-one association to Client
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "xxB", nullable = false)
@JsonBackReference
private B b;
...getters setters
}
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")
public class B implements Serializable {
........
//bi-directional many-to-one association to BookedClient
@OneToMany(mappedBy = "b", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JsonManagedReference
private List <X> xxB;
........ getters setters
}
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")
public class A implements Serializable {
........
//bi-directional many-to-one association to BookedClient
@OneToMany(mappedBy = "a", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JsonManagedReference
private List <X> xxA;
........ getters setters
}
エラー:
com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'
どのように私はこのエラーを解決することができますか?あるクラスで複数の逆参照を使用することはできませんか?
各リレーションに名前の値を追加しました。私はまだ同じエラーが発生します。 – Eniss
'defaultReference'という名前で同じエラーが発生しましたか?どのように奇数 –
はい、私も '@JsonManagedReference(値=" a ")'、 '@JsonBackReference(値=" a ")と同じエラーを試しました – Eniss