ok, przerobilem to na generyczne podejscie , jednak cos mi nie pasuje, a mianowicie:
zrobilem repository:
public interface GenericRepository<T> {
public void add(T entity);
public void update(T entity);
public void remove(T entity);
public T get(Class<T> entityClass,int id);
public Collection<T> getAll(Class<T> entityClass);
}
pozniej napisalem service
public interface GenericService<T> {
public void add(T entity);
public void update(T entity);
public void remove(T entity);
public T get(Class<T> entityClass,int id);
public Collection<T> getAll(Class<T> entityClass);
}
ale czy to nie jest zle podejsice? Tzn gdybym pozniej dodawal metody juz do konkretnych klass serwisów, na przyklad klasy Owner,to:
tworze
public Interface OwnerService extends GenericService<Owner>
// jakies dodatkowe metody np. znajdz ownerow ktorzy maja psa o imieniu Burek
I wtedy
OwnerServiceImpl implements OwnerService
/////
czy jest to dobre rozwiazanie?