Persistence design contrast: a single common interface and several specialized interfaces

I am working on a base library designed to provide common interfaces to a large application designed to support multiple DBMSs (Oracle, SQLServer, MySQL, PostgreSQL, etc.). In addition, a particular class can use JDBC or JPA to interact with the DBMS.

I want to provide a contract with basic save operations involving domain classes (models), so I made this interface using generics:

public interface IDomainDAO<T> {

    public int insert(T domainObject);

    public int update(T domainObject);

    public int delete(T domainObject);

    public List<T> getList(IQueryFilter queryFilter);
}

Note: IQueryFilterdoes not apply to my problem.

I'm trying to decide if I should provide more specialized interfaces, so specific classes can implement these instead IDomainDAO, or is it just a waste of time. For instance:

public interface IUserDAO extends IDomainDAO<User>{}

, :

public class UserDAOJDBC implements IUserDAO {

    public int insert(User domainObject){...};

    public int update(User domainObject){...};

    public int delete(User domainObject){...};

    public List<User> getList(IQueryFilter queryFilter){...};
}

, , ( ):

public class UserDAOJDBC implements IDomainDAO<User> {

    public int insert(User domainObject){...};

    public int update(User domainObject){...};

    public int delete(User domainObject){...};

    public List<User> getList(IQueryFilter queryFilter){...};
}
+3
2

. , , - IUserDAO, IDomainDAO.

IUserDAO, implements IUserDAO implements IDomainDAO<User>, .

IUserDAO IDomainDAO<User>, ; IUserDAO, , IDomainDAO<User>, . , List<User> getActiveUserList().

+2

DAO . JPA, JDBC, , JPA , JPA- .
API JPA , , API EntityManager , JPA. .

, DAO , Spring DAO, , .

DAO DAO

0

All Articles