-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Stored procedures as loaders
PostPosted: Tue Feb 01, 2005 7:59 pm 
Newbie

Joined: Tue Feb 01, 2005 7:47 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.