1
在我的Spring Data Rest應用程序中,當定義了excerptProjection
時,@JsonBackReference
被忽略。使用摘錄投影時忽略@JsonBackreferenceProject
當調用GET /foos/{id}
我得到的迴應:(_link
元素都在這裏省略)
{
"text": "Foo",
"additionalText": "Additional Text",
"bar": {
"text": "Bar",
"_embedded": {
"foo": {
"text": "Foo",
"bar": {
"text": "Bar"
}
}
}
}
}
考慮:
@Entity
public class Foo {
@Id
@GeneratedValue
private Long id;
private String text;
private String additionalText;
@JsonManagedReference
@OneToOne(mappedBy = "foo", cascade = ALL)
private Bar bar;
}
和
@Entity
public class Bar {
@Id
@GeneratedValue
private Long id;
private String text;
@JsonBackReference
@OneToOne
private Foo foo;
}
與存儲庫:
@RepositoryRestResource(excerptProjection = FooPublicProjection.class)
public interface FooRepository extends CrudRepository<Foo, Long> {}
如果我刪除excerptProjection
定義,我得到以下結果:
{
"text": "Foo",
"additionalText": "Additional Text",
"bar": {
"text": "Bar"
}
}
我能做些什麼來讓Spring數據休息不會使自己的子節點內的Foo
?