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

Query Bean Generator Generates Non-Compilable Code When Entity Uses @Embeddable Inner Class For Primary Key Type #3234

Closed
raphaelNguyen opened this issue Oct 9, 2023 · 6 comments · Fixed by #3237
Assignees
Labels
Milestone

Comments

@raphaelNguyen
Copy link
Contributor

Expected behavior

Generated query bean should compile when @Entity class uses @Embeddable inner class for primary key.

Actual behavior

When generating the query bean for entities that use @Embeddable inner class for primary keys (e.g. embedded.example.OrderItem with embeddable primary key class embedded.example.OrderItem.Key), it generates the following non-compilable code.

  • A Q<ENTITY_NAME>$<EMBEDDABLE_CLASS_NAME> class is generated for the embeddable primary key class but this class is not referenced by any of the generated code (e.g. QOrderItem$Key.java is generated under the package path query for class Key).
  • The generated query.Q<ENTITY_NAME> class references a non-existent Q<EMBEDDABLE_CLASS_NAME> class without an import clause possibly expecting it to be in the same package (e.g. query.QOrderItem refers to the class QKey)

Steps to reproduce

ebean version: 13.22.1
Please refer to example project https://github.com/integrated-application-development/query-bean-generator-issue.

@rbygrave
Copy link
Member

rbygrave commented Oct 9, 2023

404 page not found for the link above.

@rbygrave
Copy link
Member

rbygrave commented Oct 9, 2023

@raphaelNguyen
Copy link
Contributor Author

Hi @rbygrave. My apologies. I created the repo in private mode and forgot to make it public after I posted the issue. Please try again now.

I've taken a look at the inner class example you gave and the only difference I can see is that I have a single if field of the inner type which I annotated with @EmbeddedId while you have 2 fields annotated with @Id.

Is the example the preferred way to model primary key in ebean?

rbygrave added a commit that referenced this issue Oct 9, 2023
rbygrave added a commit that referenced this issue Oct 9, 2023
#3234 - Query Bean Generator Generates Non-Compilable Code When Entit…
@rbygrave rbygrave self-assigned this Oct 9, 2023
@rbygrave rbygrave added the bug label Oct 9, 2023
@rbygrave rbygrave added this to the 13.23.0 milestone Oct 9, 2023
@rbygrave
Copy link
Member

rbygrave commented Oct 9, 2023

Yeah cool. I have reproduced it and fixed it. Thanks !!

@rbygrave
Copy link
Member

rbygrave commented Oct 9, 2023

Is the example the preferred way to model primary key in ebean?

I would not say that its not preferred but pretty close to 50/50 with no major advantages for either style as I see it.

@raphaelNguyen
Copy link
Contributor Author

Thanks @rbygrave for the quick fix!

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

Successfully merging a pull request may close this issue.

2 participants