Hibernate version:2.1.4
Name and version of the database you are using:Oracle 8.1.7
Hi,
I have been reading a lot of documentation and faq's about the "inverse=true" settings in a bi-directional relationship. I have actually tried this out, and it works. But as we all know, it is not very convenient to add a child record, when you have a parent child relationship with 1000's of children. Problem is you have to load all children first (if you don't want to use a bag), which is of course unacceptable.
Now, in my situation, I have a parent and a child table. The child table has a foreign key (not-null) to the parent table. I am using a bi-directional relationship, but with inverse=false.
When I want to create a new child record, I simply do the following:
- load the parent
- create a new child, using the parent's id field to set the foreign key constraint (Child.setParentId(Parent.getId())
- save the child
When I look at the SQL Hibernate produces at child creation time, I see one simple insert statement, which succeeds. Now, I don't see how the "inverse=true" setting could optimize this? I am probably missing something, but for me everything works just fine with the default (inverse=false) setting??
Regards,
Johan
|