Hello,
I'm implementing a web project in spring boot + data + angularjs. Where the client makes rest requests to the server. On the Spring side I'm using repositories to develop the database search with CrudRepository.
@RepositoryRestResource
public interface ClientRepository extends CrudRepository< Client , Integer > {
List< Client > findAll( );
}
I just need to edit the save function of the repository. I tried to create a service layer that runs the save but it is not working.
@Component( "clientService" )
@Transactional
public class ClientRepositoryImpl implements ClientService{
private final ClientRepository clientRepository;
public ClientRepositoryImpl( ClientRepository clientRepository ) {
this.clientRepository = clientRepository;
}
@Override
public String addClient( Client saved ) {
// ....
if( this.clientRepository.save( saved ) != null )
return "OK";
else
return "NOK";
}
}
Can anyone give an idea how I can create some logic before invoking the repository save? I am making the accurate record of validating the data entered on the server side and I am not sure how to validate before the repository does save. Since on the client side I make a call rest (/ clients) with the parameters to insert.