I am attempting to call an Oracle stored function via Spring Data JDBC (NOT JPA but JDBC) with the @Query
annotation:
@Repository
public interface UserRepository extends CrudRepository<User, String>{
@Query(value="? = call PKG.get_app_props()")
Object getLoginProperty();
}
Unfortunately, I'm getting an InvalidDataAccessApiUsageException
saying "given one prop, but expected 0". I understand just fine that the "? = " means it's expecting something, but I need to get the result of the function call.
However, I'm having a miserable time finding a) an example of using a @Query
annotation for a stored function (even procedures are pretty iffy), and b) finding examples for Spring Data JDBC instead of JPA.
I'll be implementing a RowMapper or ResultsetExtractor once I can get SOMETHING back from the function.
Can anyone help?
Exception per request:
org.springframework.dao.InvalidDataAccessApiUsageException: SQL [? = call PKG.get_app_props()]: given 1 parameters but expected 0
at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.<init>(PreparedStatementCreatorFactory.java:218)
at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.<init>(PreparedStatementCreatorFactory.java:197)
at org.springframework.jdbc.core.PreparedStatementCreatorFactory.newPreparedStatementCreator(PreparedStatementCreatorFactory.java:171)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.getPreparedStatementCreator(NamedParameterJdbcTemplate.java:426)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.getPreparedStatementCreator(NamedParameterJdbcTemplate.java:399)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:243)
at org.springframework.data.jdbc.repository.query.AbstractJdbcQuery.lambda$singleObjectQuery$1(AbstractJdbcQuery.java:120)