Mapping file:
<hibernate-mapping package="com.sample"> <class name="Parent" table="parent"> <id name="id" column="PARENT_ID"> <generator class="native"/> </id> <property name="name" column="PARENT_NAME"/> <set name="childList" cascade="all" inverse="true"> <key> <column name="PARENT_ID"/> </key> <one-to-many class="Child"/> </set> </class> <class name="Child" table="child"> <id name="id" column="CHILD_ID"> <generator class="native"/> </id> <property name="name" column="CHILD_NAME"/> <many-to-one name="parent" class="Parent" column="PARENT_ID" not-null="false" cascade="all"/> </class> </hibernate-mapping>
Generated Queries by Hibernate :
Hibernate: insert into parent (PARENT_NAME) values (?) Hibernate: insert into child (CHILD_NAME, PARENT_ID) values (?, ?) Hibernate: insert into parent (PARENT_NAME) values (?) Hibernate: insert into child (CHILD_NAME, PARENT_ID) values (?, ?)
hibernate generates extra insert query for parent table.
can anyone say me what i am doing worng in mapping .
|