我正在将我们的数据库从 SQL Server 2008 迁移到 Oracle,但无法让 MyBatis 工作。
给定以下示例:
UserMapper.xml(示例)
<resultMap type="User" id="UserResult">
<id property="userId" column="userId"/>
<result property="firstName" column="firstName"/>
<result property="lastName" column="lastName"/>
</resultMap>
<select id="getUsers" statementType="CALLABLE" resultMap="UserResult">
{CALL GetUsers()}
</select>
用户DAO.java
public interface UserDAO {
public List<User> getUsers();
}
SQL Server 过程
CREATE PROCEDURE [dbo].[GetUsers]
AS
BEGIN
SET NOCOUNT ON;
SELECT userId, firstName, lastName
FROM Users
END
...在 SQL Server 2008 中工作。有人可以向我解释如何从 UserMapper.xml 调用 Oracle 过程(与上面的 SQL Server 过程具有相同的名称和列)并使用 Oracle 游标填充我的 User 类?
这是我尝试过的:
<resultMap type="User" id="UserResult">
<id property="userId" column="userId"/>
<result property="firstName" column="firstName"/>
<result property="lastName" column="lastName"/>
</resultMap>
<select id="getUsers" statementType="CALLABLE" resultMap="UserResult">
{CALL GetUsers(#{resultSet,mode=OUT,jdbcType=CURSOR,resultMap=UserResult})}
</select>
我得到这个错误:
Caused by: org.apache.ibatis.reflection.ReflectionException:
Could not set property 'resultSet' of 'class java.lang.Class'
with value 'oracle.jdbc.driver.OracleResultSetImpl@476d05dc'
Cause: org.apache.ibatis.reflection.ReflectionException:
There is no setter for property named 'resultSet' in 'class java.lang.Class'