@Column insertable and updatable on ElementCollection items' fields are ignored when generating statements

Description

Consider the following setup:

The updatable and insertable properties are ignored when generating statements. In the above example this results in the following:

Not only the nonInsertable and nonUpdatable fields are attempted to set but there is an extra 5th parameter for the shadowField which is mapped to the field with the same name.

Note that the column duplicate check is passing because it does consider insertability and updatability of a field.

I have a test case and a proposed fix which I'm going to push shortly.

Activity

Show:

Former user March 15, 2019 at 12:15 AM

Fixed in master.

Dmitry Panov March 5, 2019 at 8:59 AM

Thanks Chris. Updated the PR, all tests are now passing.

Chris Cranford February 26, 2019 at 5:05 PM

I re-opened your PR in case you want to push the change I suggested to your branch. We can then retest it against the Hibernate portfolio and verify no other issues arise.

Chris Cranford February 26, 2019 at 5:01 PM

Before I dive into the test failures themselves and discuss those, I wanted to take a brief moment and discuss your change. It would seem your goal is to specifically target a unique condition as it pertains to @ElementCollection mappings. Might I suggest in order to preserve backward compatibility with legacy mappings that we alter your change slightly?

In your original PR at line #362 of AbstractCollectionPersister, you change this from

to

Instead I would suggest the following:

With this very small change to your fix; all the existing ORM and Envers tests pass including your test for this issue.

The tests I noticed which were initially impacted by this change were the following:

The common theme across all these tests is the concept of a bidirectional many-to-many relationship that is owned by both sides of the mapping rather than one side being considered an inverse. And as you pointed out, the join column mappings are specifically annotated with insertable=false, updatable=false.

I truly don't grok why the mappings are written as they are, but I am also skeptical to change them. , do you recall if there was a specific reason why they'd be done this way in a legacy version of ORM?

Anyway, my suggestion would be to make the small nugget change I proposed to specifically narrow the behavior change solely to @ElementCollection support and believe your fix would be reasonable.

Chris Cranford February 26, 2019 at 3:31 PM

, I'll take a look at your proposed fix and get back to you in a few days.

Fixed

Assignee

Reporter

Components

Fix versions

Priority

Created January 29, 2019 at 1:43 PM
Updated March 21, 2019 at 3:12 PM
Resolved March 15, 2019 at 12:15 AM
Loading...