samedi 4 avril 2015

Call service from Repository in spring boot

Am new to Spring boot, i have seen example where we create repository to perform various operarion with the given Object. here is the sample one



@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {

List<Person> findByLastName(@Param("name") String name);

}


so from the rest client if i send People jason



http://localhost:8080/people{ .... }



it inserts to the Database, internally it calls save method.


Here after calling from the REST client , i want to do some validation or business login and then insert to the database, how can i do it? It means i want to call a service method to do all the business logic and then insert so how can i call service method from repository class?


Aucun commentaire:

Enregistrer un commentaire