Hello,
on a project we are using Hibernate 3.2 to connect to a MSSQL server. We have established the connection and I can read from the database without any problem.
Now I am trying to write to the database. I must mention that the database structured is defined and I cannot modify it. Now i have create an entity for a database table
that i want to insert rows. I must use stored procedures to implement the insertion. So on the xml I use the
Code:
<sql-insert>
tag to define that Hibernate must use the
stored procedure that exists on the server. My problem (as i believe) is at the mapping of the entity id. The id is generated on the stored procedure. When I use the
Code:
<generator class="native">
I get an exception that the ID cannot be null. As I understand it this is right because Hibernate passes null as an id and lets the server to handle it. When i do not use any generator and i am trying to bind the entity properties to the parameters of the procedure, I get an exception that it cannot bind the values and on the sql code that hibernate generates i see that passes the parameters with the wrong order.
I believe the fault is at the right mapping of the id.I would like to set it so that Hibernate will pass -1 as an id to the parameter of the procedure..
I would appreciate any help, and also if you need me to upload anything else ask me.
Thanks in advance.