You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a primary key (either @Id or @EmbeddedId) has a @Converter then, when using .find() and .*Query() you get different instances of the same entity.
When EntityManager.*Query(...) is called, It seems like the AttributeConverter(s) aren't called, before it is looked up/stored in the cache.
I found out by calling .find(), and then .createQuery(), and EntityManager.remove() on the one from the query, I could still find it the entity by primary key in the cache, in the next transaction.
using Java:
openjdk version "17.0.4" 2022-07-19
OpenJDK Runtime Environment GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06)
OpenJDK 64-Bit Server VM GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06, mixed mode, sharing)
When a primary key (either
@Id
or@EmbeddedId
) has a@Converter
then, when using .find() and .*Query() you get different instances of the same entity.When EntityManager.*Query(...) is called, It seems like the AttributeConverter(s) aren't called, before it is looked up/stored in the cache.
I found out by calling .find(), and then .createQuery(), and EntityManager.remove() on the one from the query, I could still find it the entity by primary key in the cache, in the next transaction.
To Reproduce
From pom.xml:
using Java:
openjdk version "17.0.4" 2022-07-19
OpenJDK Runtime Environment GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06)
OpenJDK 64-Bit Server VM GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06, mixed mode, sharing)
Running this test:
The test fails with different values from System.identityHashCode().
Expected behavior
Expected the two objects to be same instance
The text was updated successfully, but these errors were encountered: