Open wi21165 opened 1 year ago
/cc @Sanne (hibernate-orm), @geoand (spring), @gsmet (hibernate-orm), @yrodiere (hibernate-orm)
Based on the numbers from the StackOverflow question, this does indeed seem to be a popular request.
I'll keep it mind for some upcoming Quarkus version.
In quarkus only the
@EmbeddedId
annotation is supported for composite primary keys. Therefore it's impossible to use eg. the@GeneratedValue
annotation on a part of a composite primary key.
To clarify, Quarkus works just fine with @IdClass
, as long as you use Jakarta/Quarkus/Panache APIs. Only the Quarkus extensions that implement Spring Data APIs do not handle @IdClass
.
(Just trying to make things clear for others ending up here, I know this does not address your problem)
cc @aureamunoz
Description
Hello everyone,
I came across an unsupported feature in the "quarkus-spring-data-jpa" extension which is often very usefull or quite mandatory and therefore an addition to the already fixed bug at: https://github.com/quarkusio/quarkus/issues/10870
The problem is regarding on how one can implement composit primary keys in hibernate orm. As the documentations of Hibernate shows (here) there are two ways to implement composite primary keys in hibernate:
There are of course many differenced between those two ways but the one I want to highlight is that it is only possible to use the @GeneratedValue annotation on the compositekey class when using the @IdClass variant (see).
So whats the problem with the quarkus extension? In quarkus only the @EmbeddedId annotation is supported for composite primary keys. Therefore it's impossible to use eg. the @GeneratedValue annotation on a part of a composite primary key. If you dare to try it this fancy error occurs:
I think there are quite a lot users who would benefit from this feature as there are some related questions online eg.https://stackoverflow.com/questions/61211391/are-composite-primary-keys-in-jpa-with-quarkus-possible
Let me know if anything is unclear.. Thanks
Implementation ideas
No response