2017-01-17 5 views
0

적어도 스프링 페치 리포 지 토리 (spring crud repository) 또는 페이징 저장소 (paging repository)를 사용하여 스프링 저장 프로 시저를 사용할 수 있는지 여부를 설명 할 수 있습니까?spring 데이터 리포지토리와 함께 spring storedprocedure를 사용하는 방법

스프링 저장소와 스프링 저장 프로 시저를 사용하는 기존 코드를 통합하려고합니다. 하지만 JPA를 사용하고 싶지 않습니다. 먼저 아래와 같이 JPA reporsitory 인터페이스의 통화를 엔티티

@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 
} 

의 발동을 저장 프로 시저를 선언

아래

답변

0

당신은 같은 스프링 데이터 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); 
} 
+0

OP는 JPA –

0

JPA없이 jdbc와 직접 작동하는 공식 스프링 데이터 모듈은 없습니다.

그러나 약간 정체되어 있더라도 https://github.com/jirutka/spring-data-jdbc-repository 오픈 소스 프로젝트가 있습니다. 실제로 하위 클래스를 만들면 저장 프로 시저/jdbc 템플릿을 사용하는 메서드로 메서드를 추가하거나 재정의 할 수 있습니다.이 작업을 위해 필요한 것은 모두 DataSource입니다.

+0

을 사용하지 않으려 고 시도해 주셔서 감사합니다. – shiva