Fields annotated with @Column(updatable=false) are not inserted properly after persist() is called
Description
Activity
Show:
Olivier Hubaut October 16, 2019 at 7:53 AM
Disregard this issue. I got confused by the fact that Hibernate does not flatten events that occurs on a given entity at flush time, but rather perform an insert followed by an update.
JPA specification mentions that a fields annotated with
@Column(updatable =false)
should not be taken into consideration for SQL UPDATE queries.However, Hibernate does not comply with the spec as it prevents any modification of such field to be saved after the call to
EntityManager.persist()
has been made on that entity, although no SQL insert has been performed to this point.You can find a simple reproducible example here.
It results in data loss in applications that relies in the fact that the JPA specs are enforced.
This is currently putting a severe burden on a team that is trying to migrate from EclipseLink to Hibernate.