-
Notifications
You must be signed in to change notification settings - Fork 38.5k
SimpleJdbcCall with rowMapper set fails on execution (on Postgres) [SPR-16709] #21250
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
Comments
Juergen Hoeller commented So the Postgres driver complains that the call was declared with an out parameter of type |
Ivan Vasilev commented I wrote one more test with explicitly declared parameters (note the commented line): @Test
public void callStoredFunction() throws Exception {
SimpleJdbcCall call = new SimpleJdbcCall(jdbc)
.withFunctionName("find_customer")
// .returningResultSet("customer", (rs, i) -> new Customer(rs.getInt("id"), rs.getString("name")))
.withoutProcedureColumnMetaDataAccess()
.declareParameters(
new SqlParameter("in_id", Types.INTEGER),
new SqlOutParameter("id", Types.INTEGER),
new SqlOutParameter("name", Types.VARCHAR)
);
MapSqlParameterSource params = new MapSqlParameterSource("in_id", 2);
call.execute(params);
} This test passes successfully. But if I uncomment line setting RowMapper to call, test fails with following stack trace:
|
Ivan Vasilev commented I think it may be handy to add an Postgres initialization code. As you can see, I do not use cursors. CREATE TABLE customer
(
id INTEGER PRIMARY KEY,
name VARCHAR
);
CREATE FUNCTION find_customer(IN in_id INTEGER)
RETURNS customer
AS $$
SELECT * FROM customer WHERE id = in_id LIMIT 1;
$$ LANGUAGE SQL; |
Juergen Hoeller commented I guess Postgres goes into a different mode of execution once you specify a At this point it's still unclear to me what we could be doing about it at Spring JDBC level. It might help to recode this using the plain JDBC API against the Postgres driver and see whether you get the same results, or ideally what can you do at that level to make it work with a |
Ivan Vasilev commented I think I found something. PostgresCallMetaDataProvider.isReturnResultSetSupported() (here) returns I don't know the code base so it can be correct. But why? I guess the problem is here. |
Hello everyone. |
Thanks for the sample. Upgrading to a recent version of the framework and postgres, this leads to:
I believe this should be fixed by #31550. We can get back to this problem once we've made progress there. |
I was wrong. I did investigate this a bit more but the function in the sample doesn't return a |
@adolin-negash I've also tried to run your sample but didn't manage to get postgres to return a |
Ivan Vasilev opened SPR-16709 and commented
Further to my previous issue #21152.
spring-jdbc: 4.3.15
org.postgresql:postgresql: 9.4.1212.jre7
I've got 4.3.15 yesterday. And tested it with demo project which I attached to #21152. Test passes, so issue is resolved, thank you.
I wrote a stored function that returns a table row. When I call it returning a map of values, everything works properly. But when I set jdbcCall.returningResultSet("resultvalue", rowMapper), something goes wrong:
I attach the sample project below.
Affects: 4.3.15
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: