If you want to create your own Repos (and not spring data which does some work for you) your example isn't bad, i am using a similar strategy in one application.
Here a few thoughts to improve the generic way: I've added the ID-information in my basic domain which is implemented by all domain objects:
public interface UniqueIdentifyable<T extends Number> {
T getId();
void setId(T id);
}
In the next step i've created a generic CRUDRepo:
public interface CRUDRepository<ID extends Number, T extends UniqueIdentifyable<ID>>{
ID insert(T entity);
void delete(T entity);
....
}
And I am using an abstract class for the CRUDRepo:
public abstract class AbstractCRUDRepo<ID extends Number, T extends UniqueIdentifyable<ID>> implements CRUDRepo<ID, T>, {...}
a domain repo api will now look like:
public interface UserRepo extends CRUDRepo<Integer, User > {
User mySpecificQuery(..);
}
and finally you can implement your repo via:
public class UserRepoImpl extends AbstractCRUDRepo<Integer, User > implements UserRepo {
public User mySpecificQuery(..){..}
}