Skip to content

Instantly share code, notes, and snippets.

@3gcodes
Created February 25, 2009 03:44
Show Gist options
  • Save 3gcodes/69985 to your computer and use it in GitHub Desktop.
Save 3gcodes/69985 to your computer and use it in GitHub Desktop.
public class SqlMapBaseDao<T, ID extends Serializable> extends SqlMapClientDaoSupport implements Dao<T, ID> {
private Class<T> entityClass;
@Autowired
@SuppressWarnings("unchecked")
public void init(SqlMapClient sqlMapClient) {
entityClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
setSqlMapClient(sqlMapClient);
}
@SuppressWarnings("unchecked")
public SqlMapBaseDao() {}
@SuppressWarnings("unchecked")
public List<T> read() {
return getSqlMapClientTemplate().queryForList(entityClass.getSimpleName() + ".findAll");
}
public T read(ID id) {
return null;
}
@SuppressWarnings("unchecked")
public void save(T t) {
getSqlMapClientTemplate().insert(entityClass.getSimpleName() + ".insert", t);
}
public void delete(T t) {
}
public T findBy(String fieldName, Object value) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment