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

Allow entity classes to be scanned at build-time #30523

Closed
snicoll opened this issue Apr 4, 2022 · 2 comments
Closed

Allow entity classes to be scanned at build-time #30523

snicoll opened this issue Apr 4, 2022 · 2 comments
Assignees
Labels
status: superseded An issue that has been superseded by another theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement

Comments

@snicoll
Copy link
Member

snicoll commented Apr 4, 2022

EntityScanner is used in several places in our Spring Data integration to provide the Set of entity classes. We should replace this runtime behavior by scanning the target entities at build-time, and write these somewhere so that the runtime can pick it up.

This applies to: Couchbase, Elasticsearch, MongoDB, Neo4j. For some reason, Cassandra isn't using EntityScanner directly (although it looks like it could).

@snicoll snicoll added the type: enhancement A general enhancement label Apr 4, 2022
@snicoll snicoll added this to the 3.0.x milestone Apr 4, 2022
@snicoll snicoll added the theme: aot An issue related to Ahead-of-time processing label Apr 4, 2022
@snicoll snicoll self-assigned this Apr 5, 2022
@snicoll
Copy link
Member Author

snicoll commented Apr 5, 2022

I've had a first pass to this in snicoll@a1635a0. It consists of hiding EntityScanner behind a strategy interface so that we can replace it by something that doesn't do scanning.

There are a few bits missing here:

  • The injection is quite fragile at the moment as we could have multiple EntityProvider beans in the context. It would be better if we could qualify in its type the target data store? I don't see how that's relevant in the actual type though.
  • From an AOT perspective, it would be nice to be able to tell that those beans can be instantiated at build-time. We would be doing this, getting the set and then replacing the bean definition with the hard-coded list.
  • The link between the auto-configuration packages and the scanner are hidden behind BeanFactory. There isn't a dependency that we can use to force the container to resolve the values that we need. As such, we need to be careful when we instantiate that bean at build-time as other beans may not have contributed to the auto-configured packages yet?

@snicoll
Copy link
Member Author

snicoll commented Sep 19, 2022

The work in spring-projects/spring-framework#28287 has introduced a PersistenceManagedTypesthat's configured for JPA. For other stores, Spring Data as a ManagedTypes that seems to do what we need.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2022
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Sep 19, 2022
@snicoll snicoll removed this from the 3.0.x milestone Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant