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

When class is annotated with @MappedSuperclass, its private fields can't be accessed from JPA with native image #2127

Merged
merged 2 commits into from Sep 15, 2020

Conversation

Tomas-Kraus
Copy link
Member

Added set of jUnit tests to demonstrate this issue and verify that it's fixed.
Fixed native image support to process @MappedSuperclass private fields properly.

Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done a big change in HelidonReflectionFeature (switching to a scanning tool and no longer using unsupported APIs in this class).

@tomas-langer
Copy link
Member

@ljnelson could you please review as well to make sure we use as much of the API as possible (and in the right way). Thanks

…s properly.

Signed-off-by: Tomas Kraus <Tomas.Kraus@oracle.com>
@Tomas-Kraus
Copy link
Member Author

Tomas-Kraus commented Sep 8, 2020

Applied this patch on top of the master branch and see tests failures with native image. All of them have the same cause:

Exception: No identifier specified for entity: io.helidon.tests.integration.jpa.model.City
  org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:266)
  org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:211)
  org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:781)
  org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:254)
  org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:230)

This is what google knows about this exception:
You are missing a field annotated with @Id. Each @Entity needs an @Id - this is the primary key in the database.

But City @Entity extends Settlement @MappedSuperclass which has @Id annotation defined. Such a model works fine outside native image.

Signed-off-by: Tomas Kraus <Tomas.Kraus@oracle.com>
@Tomas-Kraus
Copy link
Member Author

Tomas-Kraus commented Sep 10, 2020

Exception: No identifier specified for entity: io.helidon.tests.integration.jpa.model.City was fixed by adding MappedSuperclass into reflection config.

Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tomas-Kraus Tomas-Kraus merged commit 386a734 into helidon-io:master Sep 15, 2020
@Tomas-Kraus Tomas-Kraus linked an issue Sep 15, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants