Вы можете вызвать хранимую процедуру в Spring Data JPA, как показано ниже
Первых Объявите хранимую процедуру в Entity
@Entity
@Table(name = "MY_TABLE")
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(name = "proc_with_input",
procedureName = "pkg.proc_with_input",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "inputParam", type = String.class)
}),
@NamedStoredProcedureQuery(name = "proc_with_input_output",
procedureName = "pkg.proc_with_input_output",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "inputParam", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "outputParam", type = String.class)
})
})
public class MyTable implements Serializable {
// Table properties
// Setters and Getters
}
взывает к прокам в reporsitory интерфейса JPA, как показано ниже.
public interface MyTableRepository extends CrudRepository<MyTable, Long> {
@Procedure(name = "proc_with_input")
public void inOnlyTest(@Param("inputParam") String inputParam);
@Procedure(name = "proc_with_input_output")
public String inAndOutTest(@Param("inputParam") String inputParam);
}
OP не хочет использовать JPA –