Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Using Springs plug-in
Full stack trace of any exception that occurs:
NA
Name and version of the database you are using:
DB2
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hi
I am using Hibernate3.0 plugging in into Spring. Now, The below are the sequence of actions I am doing.
1. Getting parent object info using getById() method.
2. Setting the Parent object into Child object and then adding child to Parent.
3. In hbm.xml files.
a) Parent: <set .... lazy="false" cascade="all" inverse="true" ....
<one-to-many>
</set> . Added to this the Id has declared as "native"
b) Child: <many-to-one ......./> . Added to this the Id has declared as "native"
Now, when I am trying to save the by calling getHibernateTemplet().saveorupdate(child). The save is failing as DataIntigrityException as the parent id and the group Id are going as "null".
But when I put cascade="all" in child, it is going fine and saving. The problem here is it is saving in both parent and child tables. but I don't want to save in parent table.
Please help me on this.
Read this:
http://hibernate.org/42.html