【发布时间】:2020-11-13 07:39:50
【问题描述】:
我使用spring-data-jpa:2.1.9.RELEASE(Spring boot 2.1.6 RELEASE)调用oracle存储过程
程序:
procedure proc(data in varchar2, res1 out number, res2 out number)
begin
insert into table (id, data) values (abc.hibernate_sequence.nextval, data)
returning id into res1;
res2 := id*5;
end proc;
实体
@Entity
@Table(name = "table", schema = "abc')
@NamedStoredProcedureQuery(name = "testName", procedureName = "proc", parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "data", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "res1", type = Long.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "res2", type = Long.class)
})
public class testEntity { ... }
存储库
@Repository
public interface TestEntityRepository extends JpaRepository<TestEntity, Long> {
@Transactional
@Procedure(name = "testName")
Map<String, Long> procedure(@Param("data") String data);
}
当我开始申请时:
IllegalArgumentException: Failed to create query for method public abstract java.util.Map TestEntityRepository.procedure(java.lang.String)!
No property procedure found for type TestEntity
如果我使用只有 1 个输出参数的存储过程,一切都很好。
【问题讨论】:
标签: java oracle stored-procedures spring-data-jpa