Hello All,
I create bidirectional associations,
simular to paragraph "6.3.3. Bidirectional associations with indexed collections" from "Hibernate Reference Documentation",
(and
http://www.hibernate.org/116.html#A12)
As collection I use list.
I add to parent object one child object.
When save new parent object, child object inserted, and after that updated.
Question: How I can remove update for child after saving new parent object,
or maybe someone know for what this update when save new object?
Possible, present way for unidirectional association without updating.
Thanks.
Hibernate version:
3.1.3
Mapping documents:
--*- Parent class collection mapping --
Code:
<list
name="values2"
cascade="all">
<key
column="PARENT_ID"
not-null="true">
</key>
<list-index column="CHILD_IDX" />
<one-to-many class="testhibernate.ChildEntity" />
</list>
--*- child class mapping ---
Code:
<many-to-one
name="parent"
column="PARENT_ID"
not-null="true"
insert="false"
update="false" />
Name and version of the database you are using: Oracle 10.
The generated SQL (show_sql=true):--*- sql after saving one parent object with child --
Code:
Hibernate:
select
SEQ.nextval
from
dual
Hibernate:
select
SEQ.nextval
from
dual
Hibernate:
/* insert testhibernate.ParentEntity
*/ insert
into
A_TEST
(id)
values
(?)
Hibernate:
/* insert testhibernate.ChildEntity
*/ insert
into
A_TEST_CHILD
(PARENT_ID, CHILD_IDX, id)
values
(?, ?, ?)
Hibernate:
/* create one-to-many row testhibernate.ParentEntity.values2 */ update
A_TEST_CHILD
set
PARENT_ID=?,
CHILD_IDX=?
where
id=?