public abstract class BaseDao<T, PK> implements IBaseDao<T, PK> {
@Resource
protected SqlSession sqlSession;
protected String nameSpace;
{
Type type = this.getClass().getGenericSuperclass();
if (type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) pType.getActualTypeArguments()[0];
nameSpace = clazz.getName();
} else {
nameSpace = null;
}
if(nameSpace == null) {
throw new RuntimeException("no name space specialed for mybaits");
}
}
}
@Resource
protected SqlSession sqlSession;
protected String nameSpace;
{
Type type = this.getClass().getGenericSuperclass();
if (type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) pType.getActualTypeArguments()[0];
nameSpace = clazz.getName();
} else {
nameSpace = null;
}
if(nameSpace == null) {
throw new RuntimeException("no name space specialed for mybaits");
}
}
}