-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hibernate 'could not resolve property' issue with Composite ID / @IdClass #1436
Comments
Is your Id property named “id”? I am asking because in Hibernate “id” is also used as a way to reference the IdClass object in queries, which may collide with your composite key. It also could be related to Quarkus. I am using IdClass with Blaze-Persistence core/criteria/querydsl all the time. The only known limitations wrt composite keys lie in entity views. |
Thanks for your response @jwgmeligmeyling!
If I understand you correctly, then yes.
I used Quarkus solely for this reproducer as it was a very fast way with minimal additional file noise (the error is identical, however, on all platforms). Apiman does not have a Quarkus distribution yet. The current Apiman Manager distros are TomCat, WildFly, & Jetty. It works fine when not using BlazePersistence, and the error occurs identically on all of the above, as far as I can ascertain.
Thanks. Interesting; I'll try fiddling with the reproducer some more to see if that makes any difference. |
Hi @msavy, I'll look into this later this week as this is probably pretty easy to fix. |
Wonderful, thanks @beikov - hopefully I can progress some other areas of the Apiman code in the meanwhile and cycle back onto this before I need to release upstream. I guess I could use QueryDSL directly as a standin temporarily if needed and I run out of time before. The code for the standard JPA Criteria API is just so bizarre that the other Apiman contributors couldn't understand it, and it was proving a nightmare to maintain.
re: @jwgmeligmeyling's idea -- unfortunately I didn't have any luck by changing this around |
Ok, so I looked into this and unfortunately this is a limitation of Hibernate when it comes to associations for entities with id classes. I created https://hibernate.atlassian.net/browse/HHH-15051 for this and already have a fix for Hibernate ready. I hope it's ok that you have to update Hibernate to 5.6.6.Final? |
In the Apiman upstream we're using Hibernate 5.3.20.Final -- we generally track the version being used in the version of WildFly we support. I suppose I could try to force it to use a different version by using jboss modules, but I am not sure if that will break something else. This particular relationship I've distilled in the reproducer has been in use in Apiman since about 2014 from what I can see. So I guess the Hibernate limitation only impacts applications such as BlazePersistence? It seems to have worked for years in terms of using Hibernate itself. |
Ughh, I feared that this could be the case.
Well, usually Hibernate allows access to the property types/columns etc. by property path per entity type. So usually, I can ask Hibernate for the type of I will implement a workaround for this limitation. |
Aha, your explanation makes sense. Thanks for that! |
…an entity type that has an id class
@beikov -- I can confirm that your fix works for Apiman using the 1.6.6.Final-SNAPSHOT build from #1438 / master (as of this post). Hopefully when Apiman 3.x lands we'll be using BlazePersistence instead of JPA Criteria API. A few small issues to iron out (re: pagination & ordering), but hopefully can get them figured out today. Thanks again for your help 🎉. |
…an entity type that has an id class
Description
I'm trying to port Apiman to use BlazePersistence instead of the JPA Criteria API to avoid losing my mind with its bizarre syntax 😂.
However, I seem to have hit a blocker.
We use composite keys/ids in our model in a few places via
@IdClass
. This is something we can't change for compatibility reasons (unless there's a compatible workaround you are aware of).It seems that the particular
@Entity
design we're using works fine with CriteriaAPI, standard Hibernate, etc, but trips up Blaze Persistence somehow. This may be related to #399, not sure?The TL;DR is that it seems it can't traverse that ID properly, and the only thing I can think of is
@IdClass
.Expected behaviour
Should be able to handle this
@Entity
sample's graph, as it works in Hibernate + Criteria API.Actual behaviour
The error displayed is:
Steps to reproduce
. https://www.github.com/msavy/reproducer-for-blazepersistence.git
.
./mvnw compile quarkus:dev
(or whatever you prefer).. First, see
Main.java
for bootstrapping, and thenio.apiman.manager.api.beans.*
.
@IdClass
seems to work in some simpler setups, but not this one.Environment
Please see reproducer for additional details, but:
Version: 1.6.5
JPA-Provider: Hibernate: 5.6.4
DBMS: com.h2database.h2-1.4.197.jar
Application Server: Quarkus
The text was updated successfully, but these errors were encountered: