Hibernate version:
3.0
Mapping documents:
<hibernate-mapping>
<class
name="ContactType"
>
<id
name="type"
column="contact_type"
type="java.lang.String"
unsaved-value="null"
>
<generator class="assigned">
</generator>
</id>
<property
name="desc"
type="java.lang.String"
update="true"
insert="true"
column="description"
length="20"
/>
<sql-insert callable="true">{call create_contact_type(?,?)}</sql-insert>
</class>
</hibernate-mapping>
Name and version of the database you are using:
Oracle 9i
Stored procedure is:
CREATE OR REPLACE PROCEDURE create_contact_type
(p_type IN varchar2,
p_desc IN varchar2) IS
BEGIN
INSERT INTO CONTACT_TYPE (CONTACT_TYPE, DESCRIPTION)
VALUES (p_type,p_desc);
commit;
END;
/
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Right now, I have an application that uses numerous stored procedures. I am trying to access these stored procedures through hibernate. After calling session.save(contactType), the data gets saved to the database but the data is switched around. Type column contains Description data and Description column contains Type data. It seems like when hibernate binds to the ? parameters, it puts Type value last since it is an ID. Is there any way to tell hibernate to do Type first and then Description. It seems like reordering the parameters in the mapping file does not work since "Type" is an id. Changing the order of parameters in the stored procedure is not a valid option since this is an existing application. Is there a patch for support of named parameters : in custom sql? Is there a workaround for this?
_________________ DBH
|