Hibernate version: 3.0beta2
Hi,
I have to use a stored procedures in order to "select" the data from the legacy database. I cannot access directly to the tables of this database because these stored procedures encapsulate a very complex business rules... I have to reuse them. I have 500-600 SP to map to my java object model.
In order to have a simple example I wrote a trivial stored procedure:
Code:
CREATE OR REPLACE PROCEDURE get_emp (myid IN NUMBER, myname out VARCHAR2) AS
CURSOR mycur is select e.name from EMPLOYEE e where e.id = myid;
myrec mycur%rowtype;
BEGIN
myname := null;
open mycur;
fetch mycur into myrec;
myname := myrec.name;
close mycur;
END get_emp;
It assumes that I have a table EMPLOYEE whose columns are ID and NAME.
And here is my Hibernate mapping file:
Code:
<class name="com.mycompany.StorProcEmployee" mutable="false">
<id name="id">
<generator class="increment"/>
</id>
<property name="name" not-null="false"/>
<loader query-ref="load-emp"/>
</class>
<sql-query name="load-emp" fetch-size="1">
<return alias="p" class="com.mycompany.StorProcEmployee"/>
{ call GET_EMP ( ?, ? ) }
</sql-query>
Unfortunately, this mapping does not work. So my question is: It is possible to map java objects to database stored procedures (and how) ? If not, is there any planning to support them?
Thanks in advance, Radenko