When @GeneratedValue uses @IdClass it works and Why doesn't it work when using @EmbeddedId?

First of all, please understand that I live in a country where I wrote the text using a translator instead of using English.

Just like the title, why does @GeneratedValue work when using @IdClass, but not when using @EmbeddedId?

I followed the link and used @GeneratedValue as a composite key, but it didn’t work for @EmbeddedId, but worked correctly for @IdClass.
Do you know the cause?

Using nested value generation inside composite identifiers was previously only supported for @IdClass. Support for @EmbeddedId was introduced with [HHH-15074] - Hibernate JIRA since version 6.4.0.

1 Like

First of all, thank you!
I thought it was a functional problem or a different operation method.

Additional questions!
Currently I am using spring-boot-starter-data-jpa.
Is that why you couldn’t use Hibernate 6.4.0 version?
How do I use Hibernate 6.4.0 and JPA together?

Hibernate is a JPA (Jakarta Persistence) provider, so everytime you’re using Hibernate you are using JPA :wink:

Jokes aside, you can try to upgrade you Hibernate ORM dependency to version 6.4.1.Final (latest release at the time of writing) and see if it works with Spring Data JPA. If it doesn’t, I’m afraid you will have to ask the Spring folks and upgrade to a Spring version that supports it when available.

lol :smile:
Thank you, I solved it easily.
All I had to do was change the version of Hibernate.
Thank you.