# @Generate not working in some cases in Hibernate 6.5.3

**URL:** <https://discourse.hibernate.org/t/generate-not-working-in-some-cases-in-hibernate-6-5-3/10526>\
**Category:** Hibernate ORM\
**Created:** [October 28, 2024, 9:57pm UTC](https://discourse.hibernate.org/t/generate-not-working-in-some-cases-in-hibernate-6-5-3/10526 "2024-10-28T21:57:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![epernice](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/epernice/32/3563_2.png) [@epernice](https://discourse.hibernate.org/u/epernice)\
**Post date:** [October 28, 2024, 9:57pm UTC](https://discourse.hibernate.org/t/generate-not-working-in-some-cases-in-hibernate-6-5-3/10526/1 "2024-10-28T21:57:41Z")

</div>

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):

```auto
    @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`

```auto
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](https://hibernate.atlassian.net/browse/HHH-18259). 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?

---

<div class="post-metadata">

**Author:** ![mbladel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbladel/32/2128_2.png) [@mbladel](https://discourse.hibernate.org/u/mbladel)\
**Post date:** [October 30, 2024, 10:06am UTC](https://discourse.hibernate.org/t/generate-not-working-in-some-cases-in-hibernate-6-5-3/10526/2 "2024-10-30T10:06:44Z")

</div>

@epernice this is probably a bug. Since Hibernate 6.5, generated values are retrieved within the mutation statement itself through JDBC APIs which allow retrieving output columns in one single statement. Previously, this happened with a subsequent select, so I’m thinking there might be some timing related issue at play, though I find it weird that one of the properties generated by the same trigger is retrieved correctly and the other one isn’t.

Maybe it’s related to the `Boolan` type within Oracle. Would you please try to create a simplified [reproducer test case](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) and open a new issue in [our tracker](https://hibernate.atlassian.net/browse/HHH)? We should look into this.

---

<div class="post-metadata">

**Author:** ![epernice](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/epernice/32/3563_2.png) [@epernice](https://discourse.hibernate.org/u/epernice)\
**Post date:** [October 31, 2024, 7:13pm UTC](https://discourse.hibernate.org/t/generate-not-working-in-some-cases-in-hibernate-6-5-3/10526/3 "2024-10-31T19:13:07Z")

</div>

Thanks - I filed [HHH-18805](https://hibernate.atlassian.net/browse/HHH-18805). When I investigated more for the minimal reproduction, I discovered that the problem arises when setting a value in Oracle compound trigger AFTER STATEMENT
