how to create my queru in spring roo -
i beginner.
i try created custom finder. , used "repository jpa " command. repository:
@roojparepository(domaintype = speaker.class) public interface speakerrepository { @query("select u speaker u 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.,,,,
your repository interface. spring data supposed auto-detect queries based on name of method, such "list findusersbynamedesc(string name);" auto-create method query users given name. @query tells not guess @ query, use 1 provide instead. example can found here.
Comments
Post a Comment