1

I've class called Parent which has OneToMany connection with another class 'Kid'. Parent containst a List of kids. Kids contains field 'name'. Could somebody help me with how CrudRepository method and REST method should look like ? I wanna ask for Parent, giving only kid's name to method.

So far i've got : a) crud repository method

Parent findByName(String name);

which is giving me an error (becouse Name is not Parent's Field)

b) rest method

@RequestMapping("parentByKidName/{name}")
@ResponseBody 
public Parent getParentByKidName(@PathVariable String name) {
return repository.findByName(name);

Could somebody help me please? }

newbie101
  • 45
  • 5
  • not possible with just attribute of child key. for that you need to add specification for search. refer this link http://stackoverflow.com/questions/34853085/spring-jpa-criteriabuilder-search-in-a-list/34853844#34853844 – Harshal Patil Feb 02 '16 at 04:36

0 Answers0