Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @NamedStoredProcedureQueries with Spring Jpa(@NamedStoredProcedureQueries with Spring Jpa and EclipseLink)
@NamedStoredProcedureQueries with Spring Jpa [message #1794549] Sun, 02 September 2018 05:39
Daniel Araujo is currently offline Daniel AraujoFriend
Messages: 4
Registered: September 2018
Location: Brazil
Junior Member
Can i map ref_cursor in a select returned by a proc with "NamedStoredProcedureQuery" using annotations jpa, spring data and eclipselink?

Example:

My oracle procedures returns a cursor in a 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;

procedure find company
  
    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;


My Employee classe
    @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; 

       ...
    }

My Company class
    @Entity
    public class Company {

       @Column(name = "company_id") 
       private long  companyId;

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


Spring Repository

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

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

    }


The other fields of the "select" works but the cursor ( proc_get_company(company_id) ) on it doesn't return by annotations. :(

can you help me ?

[Updated on: Thu, 06 September 2018 22:00]

Report message to a moderator

Previous Topic:FetchGroupMonitor
Next Topic:Behaviour of changed data read by ClientSession
Goto Forum:
  


Current Time: Fri Apr 26 05:57:45 GMT 2024

Powered by FUDForum. Page generated in 0.03153 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top