[hibernate-dev] Statements issued for unidirectional one-to-many with @JoinColumn

Gunnar Morling gunnar at hibernate.org
Fri Jan 22 04:37:12 EST 2016


Hi Gail,

Also with that PR I am still seeing the extra updates during insert.
Regarding merging, which case exactly do you mean? If I add another
element to the Parent#children association, I see INSERT+UPDATE for
that, too. Is it that what you mean?

--Gunnar


2016-01-21 22:50 GMT+01:00 Gail Badner <gbadner at redhat.com>:
> Actually, that pull request will only affect merging transient entities. Are
> you seeing the extra updates when merging?
>
> On Thu, Jan 21, 2016 at 1:09 PM, Gail Badner <gbadner at redhat.com> wrote:
>>
>> 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