GenericDao extends multiple entities

361 Views Asked by At

Im using GenericDao with few entities and i want to make an a single interface and its implementation with this entities. I have 2 Dao's interface and its implementation that extends GenericDao and i want to combine them into one interface and its implementation.

Something like that:

Entity1Dao:

public interface Entity1Dao extends GenericDao<Entity1, String>{

public List<Entity1> getAllFromEntity1();
...
}

Entity2Dao:

public interface Entity2Dao extends GenericDao<Entity2, String>{

public List<Entity2> getAllFromEntity2();
...
}

And i want to combine them and make something like:

public interface MultyDao extends GenericDao<*I do not know what needs to be here*>{

public List<Entity1> getAllFromEntity1();

public List<Entity2> getAllFromEntity2();
}

and implement it..

Here is GenericDao:

package org.dao.nci.person;

import java.io.Serializable;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;

import org.springframework.transaction.annotation.Transactional;
public interface GenericDao<E,K> {
@WebMethod(exclude = true)
public String add(List<E> entities) throws Exception;
@WebMethod(exclude = true)
public String saveOrUpdate(List<E> entity) throws Exception;
@WebMethod(exclude = true)
public String update(E entity, String whereClause) ;
@WebMethod(exclude = true)
public String remove(E entity) throws Exception;
@WebMethod(exclude = true)
public String removeWhereClause(String whereClause) throws Exception;
@WebMethod(exclude = true)
public E find(K key);
@WebMethod(exclude = true)
public List <E> get(String whereClause) throws Exception ;

public String addTest(List<E> entities) throws Exception;

}

And ofc i want to use GenericDao's methods for both entities.. )

Is it possible by somehow?

0

There are 0 best solutions below