My own 2 tier solution for now is:
@Controller
@RequestMapping(value = "/api/child", produces = {"application/json",
"application/xml"})
public class ChildController extends
RepositoryBasedRestController<Child, Long, ChildRepository> {
//...
@RequestMapping(value = "parent/{id}", method = RequestMethod.GET)
@ResponseBody
public List<Comment> findByParent(@PathVariable Long id) {
List<Comment> comments = this.repository.findByParent(id);
return comments;
}
}
public interface ChildRepository extends JpaRepository<Child, Long> {
@Query("select c from Child c where
c.parent.id = ?1")
public List<Comment> findByParent(Long id);
}
Manos