i am a beginner.
I am try to created a custom finder. and used "repository jpa " command. this is my repository:
@RooJpaRepository(domainType = Speaker.class)
public interface SpeakerRepository {
@Query("select u from Speaker u where username = :un")
public List<Speaker> findllAllSpeakersNamed(@Param("un") String lastname);
}
Service:
public class SpeakerServiceImpl implements SpeakerService {
@Autowired
SpeakerRepository speakerRepository;
public List<Speaker> findllAllSpeakersNamed(String lastName) {
return speakerRepository.findllAllSpeakersNamed(lastName);
}
}
and controller:
@RequestMapping("/findASpeaker/**")
@Controller
public class FindASpeaker {
@Autowired
SpeakerServiceImpl speakerServiceImpl;
@RequestMapping(method = RequestMethod.POST, value = "{id}")
public void post(@PathVariable Long id, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) {
}
@RequestMapping
public String index(@RequestParam("lastname")String lastname) {
String Lastname=lastname;
ModelMap modle=new ModelMap ();
List<Speaker> list = speakerServiceImpl.findllAllSpeakersNamed(Lastname);
modle.addAttribute("speakers",list);
return "findASpeaker/index";
}
}
This can not work.,,,,