The most direct, and simplest solution is to user SimpleJDBCCall
and forget about JPA for this data resource. The documentation covers parameters extensively.
Something like this will work:
public class MyDao implements SomeDao {
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall procReadStuff;
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.procReadStuff = new SimpleJdbcCall(dataSource)
.withProcedureName("my_procedure");
}
public void readStuff(Long id) {
SqlParameterSource in = new MapSqlParameterSource()
.addValue("in_id", id);
Map out = procReadStuff.execute(in);
Stuff stuff = new Stuff();
stuff.setId(id);
stuff.setSomeString((String) out.get("out_some_string"));
// ...do something with Stuff POJO
}
}
This sample was pulled/modified from the sample in the docs: Documentation