ref_cursor em @NamedStoredProcedureQuery com EclipseLink

votos
0

i pode mapear ref_cursor em um seleto retornado por uma proc com NamedStoredProcedureQuery usando anotações JPA, dados de primavera e EclipseLink?

Exemplo:

Meus Oracle procedimentos retorna um cursor em um cursor:

CREATE OR REPLACE PROCEDURE get_emp (p_name IN VARCHAR2,p_recordset OUT SYS_REFCURSOR) AS 
BEGIN 
     OPEN p_recordset FOR
          select
               employee_id,
               name,
               office,
               proc_get_company(company_id) as company
           from
               table_employee
           where
               name like '%' || :p_name || '%'
END;

procedimento da empresa achado

CREATE OR REPLACE PROCEDURE proc_get_company (company_id IN NUMBER,p_recordset OUT SYS_REFCURSOR) AS 
BEGIN
   OPEN p_recordset FOR
      select
           company_id,
           company_name
      from
           table_company
      where
           company_id = :company_id
END;

Minha classe Employee

@NamedStoredProcedureQuery(name = getEmployee,procedureName = get_emp,parameters = { 
     @StoredProcedureParameter(mode = ParameterMode.IN,type = String.class, name = p_name), 
     @StoredProcedureParameter(mode = ParameterMode.REF_CURSOR,type = void.class, name = p_recordset)
})
@Entity
public class Employee {

   @Column(name = employee_id) 
   private long employeeId;

   @Column(name = name)
   private String name;

   @Column(name = office)
   private String office;

   private Company company; 

   ...
}

Minha classe Empresa

@Entity
public class Company {

   @Column(name = company_id) 
   private long  companyId;

   @Column(name = company_name)
   private String name;   
   ...
}

Repositório primavera

@Repository
public interface EmployeeDAO extends CrudRepository<Employee, Long>{

   @Procedure(name = getEmployee,outputParameterName=p_recordset)
   public List<Employee> findEmployeeByName(@Param(p_name) String name)

}

pode me ajudar ?

Publicado 02/09/2018 em 05:18
fonte usuário
Em outras línguas...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more