我正在尝试在我的工作项目中实施 MyBatis。它是一个遗留系统,它使用 vanilla JDBC 来访问数据库,仅通过存储过程。我知道要调用存储过程,MyBatis 需要一个包含存储过程输入参数的对象和另一个保存结果集的对象。不确定这是否完全正确。
为了防止在系统中创建过多的数据实体,我想重用现有的。这就是问题出现的地方。让我解释一下我面临的典型情况/场景,然后我将如何解决它。
假设我在系统中有以下数据实体:
class Account {
private int accountID;
private String accountName;
private OrganizationAddress address;
// Getters-Setters Go Here
}
class OrganizationAddress extends Address {
// ... some attributes here
// Getters-Setters Go Here
}
class Address {
private String address;
private String city;
private String state;
private String country;
// Getters-Setters Go Here
}
Run Code Online (Sandbox Code Playgroud)
我正在使用注释,所以我的Mapper类有这样的东西:
@Select(value = "{call Get_AccountList(#{accountType, mode=IN, jdbcType=String})}")
@Options(statementType = StatementType.CALLABLE)
@Results(value = {
@org.apache.ibatis.annotations.Result
(property = "accountID", column …Run Code Online (Sandbox Code Playgroud)