• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing Java Objects to Procedure

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the ORM forum.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic