-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support of nested cursors #566
Comments
Hi! Any news about this request? @dsulimchuk did you find any alternative? |
Could somebody show me how this works in JDBC? String sql = "select 1 id, cursor(select level from dual connect by level >= 5) coll from dual";
try (Connection con = new JdbcConnection("oracle18").getConnection();
PreparedStatement stmt = con.prepareStatement(sql);
ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
int id = rs.getInt("id");
// How to get the 'coll' value?
}
} |
|
Okay. Then you may be able to write a type handler as a workaround. <resultMap type="map" id="rm">
<id column="id" property="id" javaType="int" />
<result column="coll" property="coll" typeHandler="test.CursorTypeHandler" />
</resultMap>
<select id="selectNestedCursor" resultMap="rm">
select 1 id,
cursor(select level from dual connect by level >= 5) coll from
dual
</select> public class CursorTypeHandler extends BaseTypeHandler<Map<String, Object>>{
@Override
public Map<String, Object> getNullableResult(ResultSet rs, String columnName) throws SQLException {
Map<String, Object> result = new HashMap<>();
try (ResultSet nestedRs = rs.getObject(columnName, ResultSet.class)){
ResultSetMetaData rsmd = nestedRs.getMetaData();
for (int i = 0; i < rsmd.getColumnCount(); i++) {
String key = rsmd.getColumnName(i + 1);
Object value = rs.getObject(i + 1);
result.put(key, value);
}
}
return result;
} It might be nice if we could reuse an existing result map. |
This is the problem. A TypeHandler cannot access the mappers, so it cannot invoke a properly configured ResultSetHandler on "value". |
It should be best if the "/mapper/resultMap/result" element could contain nested resultmaps linked to columns, e. g.: |
By specifying a special name NESTED_CURSOR to `resultSet` attribute, Should fix mybatis#566
This probably worked in earlier versions, so these tests are to ensure backward compatibility. mybatis#566 (comment)
This probably worked in earlier versions, so these tests are to ensure backward compatibility. mybatis#566 (comment)
Hello!
Can myBatis support oracle nested cursors ? https://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions005.htm
for example i have next select statement:
and take a result =
{COLL=oracle.jdbc.driver.OracleResultSetImpl@54c75937, ID=1}
please add support of evaluating nested cursors
The text was updated successfully, but these errors were encountered: