-->
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.  [ 6 posts ] 
Author Message
 Post subject: Calling a stored procedure for a given property
PostPosted: Fri Aug 13, 2004 8:45 am 
Newbie

Joined: Mon Mar 15, 2004 3:07 pm
Posts: 8
I know that there is no support for stored procedures yet in 2.1, but I have a object that maps fine to my database except for one column that I need to retrieve using a stored procedure. The data for that column comes from another table, but the logic is too complicated for any join.

What we do now, using regular jdbc, is get the result set and for each row in the result set, pass the parameters to the stored procedure to retrieve the value.

Any ideas, on how this might be accomplished using hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 8:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Not easy. Can you call the stored procedure in a plain select? like "select a, b, procedure() from table"? Then you could use a formula property.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 9:20 am 
Newbie

Joined: Mon Mar 15, 2004 3:07 pm
Posts: 8
I can call it from a select statement. How do I use this formula property? Can you just point me to the docs?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 9:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just make a property in your class where the result should be stored, and then use formula="procedure()" as attribute in the property mapping. Just try it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 11:24 am 
Newbie

Joined: Mon Mar 15, 2004 3:07 pm
Posts: 8
Does the property have to be an actual column in the table? Or do I need to create a dummy column? I have the mapping:

<property
name="settlementEntity"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="settlementEntity"
formula="pkgsca.fReturnEnty( partyB, partyA, account, boughtCurrency, soldCurrency)"
/>

But there is no column settlemententity in my table which is obviously why i need to retrieve it externally.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
just leave the column attribute out. Just try it :)


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.