//得到反射类型
private Class getGenericType(){
if(clazz == null){
Type type = super.getClass().getGenericSuperclass() ;
if(type instanceof ParameterizedType){
ParameterizedType ptype = ((ParameterizedType)type);
Type[] args = ptype.getActualTypeArguments();
clazz = args[0].getClass();
tType = args[1].getClass();
}
}
return clazz ;
}
类结构:
public abstract class BasicDaoImpl<T , PK> extends HibernateDaoSupport implements BasicDao<T , PK>{}
继承类
@Resource(name="BankDao")
protected BasicDaoImpl<Bank , Integer> bankDao ;
可以直接用Service类继承该Dao
public class BankService extends BasicDaoImpl<Bank, Integer> {} ;