Skip to content
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

Metamodel fails to instantiate on domains with nested IdClass attributes with associations #666

Closed
jwgmeligmeyling opened this issue Sep 27, 2018 · 3 comments
Assignees
Milestone

Comments

@jwgmeligmeyling
Copy link
Collaborator

jwgmeligmeyling commented Sep 27, 2018

Due to HHH-12996, a limitation of the Hibernate @IdClass implementation, the implementation of MetaModelImpl#collectIdColumns(...) has some issues with processing domains that suffer from this Hibernate issue. The code in f8cc47b#diff-c2515d6af07b654068b5c62a6567e084R199 will try to look up a nested property, which is not present in the PropertyMapping.

It's not a big blocker that this isn't supported, because apparently this construction is very rare, and even if we would be able to work around the issue, the produced query wouldn't get through the Hibernate query engine because it will fail to process the dot node due to the very same issue. It is however problematic, that due to this exception the entire generation of the metamodel fails. My suggested fix is henceforth to swallow and log the exception, but I'm open to any other suggestions as to how to work around this issue.

For a domain that shows the issue, you can use the domain from my reproducer provided in hibernate/hibernate-orm#2546

Description

Expected behavior

Actual behavior

Steps to reproduce

Environment

Version:
JPA-Provider:
DBMS:
Application Server:

@jwgmeligmeyling jwgmeligmeyling self-assigned this Sep 27, 2018
@beikov
Copy link
Member

beikov commented Sep 27, 2018

This might be fixed with #659

@jwgmeligmeyling
Copy link
Collaborator Author

I see some changes in collectIdColumns indeed , but I'm not sure whether it will work. In order to expand the association attributes for proper CTE binding, we need to resolve the properties, which means we need to create an attribute entry. The contructor of this class fails because isJoinable does a lookup against the EntityPersisters BasicEntityPropertyMapping. The attribute should be there, but isn't. Changing the code to work around this would produce the correct JPQL, but as HHH-12996 shows, because of this issue, Hibernate isn't able to parse the JPQL too. So there is no way to fix this for Hibernate unless we make use of the IdClass properties that can be obtained through the magic path attribute .id or add extra unnecessary joins to the query.

jwgmeligmeyling added a commit to jwgmeligmeyling/blaze-persistence that referenced this issue Nov 23, 2018
@jwgmeligmeyling
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants