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

Configure JpaBaseConfiguration with custom ManagedClassNameFilter #39813

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Mar 1, 2024

Fix GH-29193

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 1, 2024
String[] packagesToScan = getPackagesToScan(beanFactory);
return new PersistenceManagedTypesScanner(resourceLoader).scan(packagesToScan);
return new PersistenceManagedTypesScanner(resourceLoader, managedClassNameFilter.getIfAvailable())
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should support multiple filters and create a composite. For consistency with exposing actuator endpoints, exclude would take precedence over include. In other words, a class name would have to be matched by every filter for it to be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a class name would have to be matched by every filter for it to be included.

It's unintuitive.

Copy link
Member

Choose a reason for hiding this comment

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

It's hard to continue a discussion as you haven't described why you think that it's unintuitive. As I said above, this is how the actuator endpoints behave and that seems to be serving us well. I think the consistency would be a good thing.

Copy link
Contributor Author

@quaff quaff Mar 1, 2024

Choose a reason for hiding this comment

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

My apologize, as typical spring framework user, I’m expecting one bean available for injection, If multiple beans need to be composed, application should write a primary composite implementation they can take over the control, not hardcoded AND or OR.
l said unintuitive because I don’t know If actuator endpoints doing that way if you don’t mention it.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, @quaff. So it's more the support for multiple beans that you find unintuitive rather than how the composite created from those multiple beans would behave.

There are other places where multiple beans are supported, such as Boot's various …Customizer callbacks and things like Framework's WebMvcConfigurer. I guess we could stick with support for a single filter for now and add support for automatically composing them in the future if there's demand for it. It side-steps the need to decide if it'll be AND vs OR which is certainly a benefit.

Copy link
Member

Choose a reason for hiding this comment

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

@snicoll do you have an opinion here? Do you think there's likely to be a need for multiple filters that we compose automatically or will most users' needs be served by supporting only one. I think I'm now leaning towards only handling one in the auto-configuration.

Copy link
Member

@snicoll snicoll Mar 12, 2024

Choose a reason for hiding this comment

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

Sorry, I read that and meant to reply and I forgot about it. I honestly don't know but I'd prefer that the decision is in a central place. If users need to have multiple filters for whatever reason, I'd prefer them to do the gathering rather than us.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like we should stick with a single bean for now. Perhaps some helper factory methods can be added ManagedClassNameFilter if composing filters turns out to be a common need? E.g. ManagedClassNameFilter.allOf(f1,f2,f3).

@philwebb philwebb self-assigned this Apr 18, 2024
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 18, 2024
@philwebb philwebb added this to the 3.3.x milestone Apr 18, 2024
philwebb pushed a commit that referenced this pull request Apr 18, 2024
Update `JpaBaseConfiguration` to configure a `ManagedClassNameFilter`
if one is available.

See gh-39813
@philwebb philwebb closed this in 805bb06 Apr 18, 2024
@philwebb philwebb modified the milestones: 3.3.x, 3.3.0-RC1 Apr 18, 2024
snicoll added a commit to snicoll/spring-boot that referenced this pull request May 3, 2024
This commit documents the support of ManagedClassNameFilter that was
added in spring-projectsgh-39813.
snicoll added a commit to snicoll/spring-boot that referenced this pull request May 3, 2024
This commit documents the support of ManagedClassNameFilter that was
added in spring-projectsgh-39813.
scottfrederick pushed a commit that referenced this pull request May 3, 2024
This commit documents the support of ManagedClassNameFilter that was
added in gh-39813.

See gh-40617
snicoll added a commit to snicoll/spring-boot that referenced this pull request May 7, 2024
This commit documents the support of ManagedClassNameFilter that was
added in spring-projectsgh-39813.

See spring-projectsgh-40617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure the auto-configured LocalContainerEntityManagerFactoryBean with any ManagedClassNameFilter beans
5 participants