项目。
示例:
我的oracle过程在另一个游标中返回一个游标:
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;
程序查找公司
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;
我的员工班级
@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;
...
}
我的公司课程
@Entity
public class Company {
@Column(name = "company_id")
private long companyId;
@Column(name = "company_name")
private String name;
...
}
Spring存储库
@Repository
public interface EmployeeDAO extends CrudRepository<Employee, Long>{
@Procedure(name = "getEmployee",outputParameterName="p_recordset")
public List<Employee> findEmployeeByName(@Param("p_name") String name)
}
问题:
如何使用批注将光标( proc_get_company(company_id)作为公司)映射到另一个具有“ NamedStoredProcedureQuery”,Spring数据和eclipseLink的“选择光标”(p_recordset)中?
注意: 它可以使用“选择”的其他字段,但是其上的光标(proc_get_company(company_id))不会通过注释返回。 :(
你能帮我吗?