-->
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: How to call stored procedure and insert in db correctly
PostPosted: Thu Jun 22, 2006 9:05 pm 
Beginner
Beginner

Joined: Fri Jun 10, 2005 11:51 pm
Posts: 45
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

3.1.2 rc2:

hello, can someone show me how to call a stored procedure correctly?actually, i already called a stored procedure in hibernate mapping but the fields does not correctly put in place..eg. i call a stored like this <sql-insetrt>{ ? = MY_SP(?,?,?,?,?)}</sql-insert> which has 5 parameters..but the data inserted in the database are switch or not put in right fields were should it be..can some tells me whats going wrong..and one yhing i keep arranging the hibernate mapping to put in exact fields of database...tnx

my hbn mapping:

<hibernate-mapping package="com.ifafa.reg.forms">
<class name="Test" table="Test">
<id name="par_Status" column="Status" type="java.lang.Character">
<!--generator class="assigned"/-->
</id >

<property name="par_ID" column="ID" not-null="true" type="java.lang.Long" />
<property name="par_Username" column="Username" not-null="true" type="java.lang.String"/>
<property name="par_Password" column="Password" not-null="true" type="java.lang.String" />
<property name="par_SiteID" column="siteID" not-null="true" type="java.lang.Long" />





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

</class>
</hibernate-mapping>

MySQL 5


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 11:28 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
From the ref docs, section 16.4:

The order of the positional parameters are currently vital, as they must be in the same sequence as Hibernate expects them.

You can see the expected order by enabling debug logging for the org.hibernate.persister.entity level. With this level enabled Hibernate will print out the static SQL that is used to create, update, delete etc. entities. (To see the expected sequence, remember to not include your custom SQL in the mapping files as that will override the Hibernate generated static sql.)

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 11:50 pm 
Beginner
Beginner

Joined: Mon Jul 26, 2004 4:29 pm
Posts: 45
Location: TX, USA
Hi,

The reference manual has this to say:

Quote:
The order of the positional parameters are currently vital, as they must be in the same sequence as Hibernate
expects them.
You can see the expected order by enabling debug logging for the org.hiberante.persister.entity level.
With this level enabled Hibernate will print out the static SQL that is used to create, update, delete etc. entities.
To see the expected sequence, remember to not include your custom SQL in the mapping files as that will override
the Hibernate generated static sql.


Perhaps turning debug level logging on as noted above will show you what Hibernate is expecting as far as parameter order is concerned?

Hope this helps,


Top
 Profile  
 
 Post subject: stored procedure question
PostPosted: Thu Jun 22, 2006 11:54 pm 
Beginner
Beginner

Joined: Fri Jun 10, 2005 11:51 pm
Posts: 45
thnak for the reply...im kind of newbie here..can you give me how to turn the org.hiberante.persister.entity level?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 12:24 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Edit the log4j.properties file in the top level of your classpath. Have it include this line:
Code:
log4j.logger.org.hibernate.persister.entity=DEBUG

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject: stored procedure question
PostPosted: Fri Jun 23, 2006 1:50 am 
Beginner
Beginner

Joined: Fri Jun 10, 2005 11:51 pm
Posts: 45
based from im posted:
Quote:
<hibernate-mapping package="com.ifafa.reg.forms">
<class name="Test" table="Test">
<id name="par_Status" column="Status" type="java.lang.Character">
<!--generator class="assigned"/-->
</id >

<property name="par_ID" column="ID" not-null="true" type="java.lang.Long" />
<property name="par_Username" column="Username" not-null="true" type="java.lang.String"/>
<property name="par_Password" column="Password" not-null="true" type="java.lang.String" />
<property name="par_SiteID" column="siteID" not-null="true" type="java.lang.Long" />





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

</class>
</hibernate-mapping>


can you suggest a better way to call a stored procedure in MySQL 5?or have a better example?thus my calling a stored procedure is correct?


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.