79282533

Date: 2024-12-15 14:40:06
Score: 0.5
Natty:
Report link

I made a simple library to hide the boilerplate part to get result of OUT parameters, it's type-safe and supports ref cursors (library available on Maven Central). It works beyond spring-jdbc. For the given example the call can look like

import static org.morejdbc.OracleSqlTypes.cursor;
import static org.morejdbc.NamedJdbcCall.call;

...
    public record Entity(String id, String value) {
    }
...

Out<List<Entity>> outUserCursor = Out.of(cursor((rs, rowNum) -> {
    // implementation of spring RowMapper: your custom ResultSet mapping here
    return new Entity(rs.getString("id"), rs.getString("value"));
}));

jdbcTemplate.execute(call("PRC_GET_USERS_BY_SECTION")
        .in("section_option_in", "value_of_section_option_in")
        .in("section_in", "value_of_section_in")
        .out("user_cursor", outUserCursor));

// outUserCursor.get() now contains List<Entity>
Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: seregamorph