updatable = false on @JoinColumn breaks update of @OrderColumn

Description

With a simple Parent -> Child relationship, with an ordered OneToMany (List).

No updates are made to the @OrderColumn if updatable = false is specified on the @JoinColumn and changes are made to the List (e.g. order change, or removal from middle of the list).

I specify
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "parent_id", nullable = false, updatable = false)
@OrderColumn(name = "child_index", nullable = false)
private List<Child> children = new ArrayList<>();
because

  • The child's lifecycle is linked to the parent

  • The parent should never update

  • I want to avoid unnecessary update Child set parent_id=?, child_index=? where id=? on inserts

But it seems it is affecting the update of the OrderColumn

Here is the test-case

Environment

Hibernate 5.4.0.Final, jdk1.8.0_45, windows, using H2 db

Status

Assignee

Unassigned

Reporter

Superbazza

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure