Hello,
I´m new to Spring Data aswell... But I think I can give you some hints...
first, this url:
http://www.petrikainulainen.net/prog...t-six-sorting/
has alot of Spring Data material. You can check it out.
Another thing, I´ve costumized my repository by doing this:
Code:
public interface BaseRepository<T, PK extends Serializable> extends PagingAndSortingRepository<T, PK>
{
public List<T> globalSearch(String value, Sort sort);
}
and my specific repository:
Code:
public interface GrupoRepository extends BaseRepository<Grupo, Integer>{
List<Grupo> findByDescricaoContaining(String descricao);
@Query("select g from Grupo g where g.descricao like '%' || ?1 || '%' OR g.tipo = ?1")
List<Grupo> globalSearch(String value, Sort sort);
}
notice that I didn´t implement the interfaces.. That is still done all by Spring ...
But if you want to add another layer before the repository i think you should do this:
Code:
public abstract class BaseService<T, PK extends Serializable> {
private BaseRepository<T, PK> baseRepository;
public BaseService(BaseRepository<T, PK> baseRepository) {
this.setBaseRepository(baseRepository);
}
public T save(T entity) {
//encrypt here, before sending it to the repository :)
return this.getBaseRepository().save(entity);
}
hope I could help