This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Java Objects to Procedure

 
Manikandan Pandurangan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Below is my mapping details in hbm file.

<class name="com.test.UserData" table="user_data" schema="xyz01">
<id name="userName" type="java.lang.String" unsaved-value="null">
<column name="USERNAME" precision="15" scale="0" />
</id>
<property name="password" type="java.lang.String" column="password"/>
<sql-insert callable="true">{call SAVE_DATA_PRC(?,?)}</sql-insert>
</class>


I am able to invoke the porcedure with the below statement hibernateSession.save(object).
How ever the object attribute and procedure arguments were not mapped exactly, the order was changed.

Do you have any idea, how to invoke the procedure with passing the java obje cts. How should do the mapping between object attributes and procedure arguments...? Please help me to fix the issue.

Thanks
Mani
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order of parameters is unfortunately vital. Either change them in the mapping file or in the procedure.
 
Manikandan Pandurangan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is my sample mapping file.


<class name="com.test.EncryptedData" table="encrypted_data" schema="iris01">
<id name="userName" type="java.lang.String" unsaved-value="null">
<column name="USERNAME" precision="15" scale="0" />
</id>

<property name="atext" type="java.lang.String" column="l_a"/>
<property name="btext" type="java.lang.String" column="l_b"/>
<property name="ctext" type="java.lang.String" column="l_c"/>
<property name="dtext" type="java.lang.String" column="l_d"/>
<property name="dataToEncrypt" type="java.lang.String" column="l_data"/>
<property name="key" type="java.lang.String" column="l_keyValue"/>
<property name="timeDifferenc" type="java.lang.Long" column="l_timeTaken"/>

<sql-insert callable="true">{call test_Save_Prc(?,?,?,?,?,?,?,?)}</sql-insert>
</class>

and the procedure declaration is

CREATE OR REPLACE PROCEDURE test_Save_Prc (
l_a in varchar2,
l_b in varchar2,
l_c in varchar2,
l_d in varchar2,
l_data in varchar2,
l_keyValue in varchar2,
l_timeTaken in number,
l_username in varchar2
)

I'm invoking the procedure with hibernateSession.save(EncryptedData)

It works only when the parameters and mapping properties were in ascending order...

How to do the mapping between the java attributes and the procedure arguments...? Can we pass objects with hierarchy to the procedure?

Could you please help on this...

Thank you
Mani
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It works only when the parameters and mapping properties were in ascending order...

Yes. As I said, the odering of parameters is vital. Changing it is not an option.


How to do the mapping between the java attributes and the procedure arguments...?

You can't explicitly map between the java object's attributes and the procedures parameters. That is done implicitly, based on the ordering of the parameters in the mapping file.


Can we pass objects with hierarchy to the procedure?

No.
[ June 01, 2006: Message edited by: Paul Sturrock ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic