I’m having a bit of trouble upgrading from Hibernate 6.4.10 to Hibernate 6.5.3. I have the following in an entity (Kotlin):
@Generated(event = [EventType.INSERT, EventType.UPDATE])
@Column(name = "version_key", columnDefinition = "VARCHAR2(1000 CHAR)", updatable = false)
var versionKey: String? = null,
@Generated(event = [EventType.INSERT, EventType.UPDATE], writable = true)
@Column(name = "is_latest", updatable = false)
var isLatest: Boolean = true,
I have a test in which I insert an object, and an Oracle database trigger sets the version_key
to a string and sets is_latest
to false
. In Hibernate 6.4.10, when I call save()
on my JpaRepository
, the object that is returned from the save()
method has the correct values that were set by the database trigger.
However, after updating Hibernate to 6.5.3, the versionKey
is set correctly, but isLatest
is set to true
. In fact, even if I manually call entityManager.refresh()
on the returned entity, isLatest
is still set to true. In Hibernate 6.5.3, I need to call findById
on my JpaRepository
(immediately after calling save) to get an entity back with the correct values. Any idea if there was a change between these two versions that would impact this behavior?
Some extra details
I’m using Spring Boot 3.3.5 which includes Hibernate 6.5.3. I can verify that solely changing my Hibernate version between 6.5.3 and 6.4.10 determines whether the test described above passes or fails. I’m changing my Hibernate version with the following in my build.gradle.kts
extra["hibernate.version"] = "6.4.10.Final"
Update: I tried a few more versions of Hibernate to get some more data points on which versions do/don’t break my test. I was surprised to discover that my test works in the earlier 6.5.x versions. Here is the breakdown:
6.4.10 - PASS
6.5.0 - PASS
6.5.1 - PASS
6.5.2 - PASS
6.5.3 - FAIL
6.6.1 - FAIL
One more update: In scrolling through the issues fixed in 6.5.3, this one caught my eye: HHH-18259: Joined Inheritence with Generated wrongly resolves columns for base entity. I didn’t think to mention this before, but my entity is a base class that uses Joined Inheritance. Is it possible that the fix for HHH-18259 caused a regression?