Skip to content

Register runtime hints for types exposed via PersistenceManagedTypes #29096

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

Closed
christophstrobl opened this issue Sep 7, 2022 · 4 comments
Closed
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@christophstrobl
Copy link
Member

By using BindingReflectionHintsRegistrar typical data binding use cases for eg. JPA would be covered.
The current registrar implementation would still miss class references in annotation attributes like in @jakarta.persistence.EntityListeners(MyEntityListener.class) but this could be handled processor.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 7, 2022
@sdeleuze sdeleuze self-assigned this Sep 7, 2022
@sdeleuze sdeleuze added this to the 6.0.0-M6 milestone Sep 7, 2022
@sdeleuze sdeleuze added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing in: data Issues in data modules (jdbc, orm, oxm, tx) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 7, 2022
@sdeleuze sdeleuze changed the title Register data binding runtime hints for types exposed via PersistenceManagedTypes Register runtime hints for types exposed via PersistenceManagedTypes Sep 7, 2022
@sdeleuze
Copy link
Contributor

sdeleuze commented Sep 7, 2022

You can find a draft commit on sdeleuze@gh-29096. It uses as expected BindingReflectionHintsRegistrar to register entities reflection hints.

The part which is more tricky is to decide what Class<?> annotation attributes we support since they will require additional hints. At least for now, I have decided to only support JPA annotations, not implementation specific (like Hibernate) ones.

If I am not mistaken, @ManyToMany, @ManyToOne, @OneToMany and @OneToOne are referencing other entities no need for additional hints there.

It is unclear if @MapKeyClass and ElementCollection will require hints, so I think I prefer to now add it for now.

@Converter can be autoapplied without @Convert via @Converter(autoApply=true) so they should probably added via a dedicated mechanism via the @Converter entry point, not the @Convert one which is optional.

So for now in my draft commit I have added support for @IdClass and @EntityListeners which looks to me a reasonable starting point, with the plan to add more support on popular enough features raised by users or our own tests.

@snicoll @christophstrobl @schauder Please let me know if this is ok from your POV or if this should be refined.

@sdeleuze
Copy link
Contributor

sdeleuze commented Sep 7, 2022

I just checked that @Converter classes are properly scanned by PersistenceManagedTypesScanner and they were supported in Spring Native so I will likely add similar support via this issue. Please let me know if you see other points to refine.

sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Sep 7, 2022
Add binding hints for managed types and hints for
@EntityListeners, @IdClass and @converter.

Closes spring-projectsgh-29096
@sdeleuze
Copy link
Contributor

sdeleuze commented Sep 7, 2022

@christophstrobl I have added support for @Converter in sdeleuze@gh-29096.

@christophstrobl
Copy link
Member Author

@sdeleuze LGTM. @schauder thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants