Guys,
I was using Hibernate for couple years and still think it is the best O/R tool ever. However, some of my superiors does not like some facts from Hibernate. The problem comes from the number of requests sent by Hibernate when it persists related entities (one-to-many per say).
Imagine we got two types of entities - Person and Name, where person can have more than one name. So fragment of Person mapping looks like this:
Code:
<bag name="NameList" table="Name" cascade="persist,delete" >
<key column="PersonId" />
<one-to-many class="Name" />
</bag>
If person got two names, from proprietary SQL coding prospective there
supposed to be three requests:
insert person;
insert first name along with foreign key (person id);
insert another name along with foreign key (person id).
However, Hibernate sends 5 requests instead:
insert person;
insert first name;
insert name;
update name with foreign key (person id);
update name with foreign key (person id).
That's what my superiors do not like. So the question is if it is possible to force Hibernate to go just with 3 insertions instead of 3 insertions and 2 updates (foreign key to be inserted along with name)?
Thank you very much in advance.
CaesarDark
Environment: Hibernate 3.1.3; Sybase