尝试使用Mybatis

时间:2018-04-25 13:42:54

标签: java mybatis

我尝试使用mybatis从Oracle数据库中读取数据。

我在db.xml中写了下面的查询:

<select id="selectItemPartNumberWithEco" resultType="String">
        SELECT ITEM_PART_NUMBER from CIS_ITEM_AGILE_ECO_DATA_TBL WHERE ECO_NUMBER IS NOT NULL
    </select>
    <select id="selectItemPartNumberWithoutEco" resultType="String">
        SELECT ITEM_PART_NUMBER from CIS_ITEM_AGILE_ECO_DATA_TBL WHERE ECO_NUMBER IS NULL
    </select>

我的db.java(接口)文件有以下声明:

public List<String> selectItemPartNumberWithEco() throws DAOException;
public List<String> selectItemPartNumberWithoutEco() throws DAOException;

我的实现类有以下代码:

public List<String> selectItemPartNumberWithEco() throws DAOException {
    return repoItemDAO.selectItemPartNumberWithEco();
}

public List<String> selectItemPartNumberWithoutEco() throws DAOException {
    return repoItemDAO.selectItemPartNumberWithoutEco();
}

我已按以下方式调用上述类:

RepoServiceImpl repoServiceObj = new RepoServiceImpl();
List<String> existingDbAgileItemList = repoServiceObj.selectItemPartNumberWithEco();
List<String> newDbAgileItemList = repoServiceObj.selectItemPartNumberWithoutEco();      

执行我的代码时,我得到空指针异常。

如何使用mybatis从数据库中选择列?

0 个答案:

没有答案