[hibernate-dev] Statements issued for unidirectional one-to-many with @JoinColumn
Gail Badner
gbadner at redhat.com
Thu Jan 21 16:09:33 EST 2016
Hi Gunnar,
Can you try using this pull request for HHH-9979 [1] to see if the extra
updates go away?
This pull request is already closed because I am going to use new
OperationContext functionality to fix HHH-9979. I know this pull request
does get rid of some updates, and the future one will as well.
Thanks,
Gail
[1] https://github.com/hibernate/hibernate-orm/pull/1067
On Thu, Jan 21, 2016 at 3:25 AM, Gunnar Morling <gunnar at hibernate.org>
wrote:
> Steve, all,
>
> I have a model with two entities, Parent and Child, and an
> unidirectional one-to-many association from the former to the latter.
>
> Via @JoinColumn on the association it is ensured that the Parent FK is
> stored in the Child table, i.e. without a separate join table. When
> inserting a Parent and several Child entities, I see the following
> statements:
>
> INSERT INTO parent (id, name) VALUES (?,?)
>
> INSERT INTO child (id, childname) VALUES (?,?)
> INSERT INTO child (id, childname) values (?,?)
>
> UPDATE CHILD SET Parent_id=? WHERE id=?
> UPDATE CHILD SET Parent_id=? WHERE id=?
>
> Why is it that the FK is propagated through separate updates instead
> of doing it as part of the Child insert?
>
> Thanks,
>
> --Gunnar
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
More information about the hibernate-dev
mailing list