Closed sdeleuze closed 11 years ago
Additional informations, this functionality should allow to fix serialization issues for children-parent when we were using previously @JsonIgnore or @JsonBackReference. Another use case is that it allows us to use again lazy loading + OpenSessionInView filter.
Here is a code sample showing these 2 improvements (not tested yet, so there may be issues) :
public class Library {
@JsonView(BookListView.class)
private List<Book> books;
}
public class Book {
@ManyToOne(fetch = FetchType.LAZY)
private Library library;
@JsonView(BookListView.class)
private String name;
@OneToMany(fetch = FetchType.LAZY)
private List<Page> pages;
}
@RequestMapping("books")
@ResponseView(BookListView.class)
public @ResponseBody List<Book> getBooks()
{
return data;
}
@RequestMapping("{id}")
public @ResponseBody Book getBook(@PathVariable("id") Integer id)
{
return data.get(id - 1);
}
great!
@bmeurant is preparing a PR regarding
@Transactional
issues. Actually, the default strategy isrequired=true
and readOnly=false; we were kind of used toreadOnly=true
because ofGenericService
in RESThub 1.x.Could you delete some parts of your PR? I'll point the exact lines to make this easier.