-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Disable Hibernate entity scanning for default JPA setup #15565
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
Disable Hibernate entity scanning for default JPA setup #15565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR but that's not really what I had in mind for this. Please see comments.
...figure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java
Outdated
Show resolved
Hide resolved
...figure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java
Outdated
Show resolved
Hide resolved
...e/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not what my first review was heading. Could you please reconsider the first review? I've also added some additional comments.
* property. When not specified will default to | ||
* "org.hibernate.boot.archive.scan.internal.DisabledScanner". | ||
*/ | ||
private String archiveScanner = "org.hibernate.boot.archive.scan.internal.DisabledScanner"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update but that's not what I meant. There shouldn't be any property at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property was removed
@@ -121,6 +138,10 @@ else if (!result.containsKey(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS)) { | |||
} | |||
} | |||
|
|||
private void applyArchiveScanner(Map<String, Object> result) { | |||
result.put(AvailableSettings.SCANNER, this.archiveScanner); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not checking if a user has set the property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added checking
@ayudovin that change broke Hibernate 5.2 support as indicated by the build failure. Have you noticed it? |
@snicoll, yes, I try to find solution. Hibernate 2 doesn't have DisabledScanner and I haven't found a solution yet. As far as I understand we can't change version to 5.3, can we ? |
* pr/15565: Polish "Disable Hibernate entity scanning for default JPA setup" Disable Hibernate entity scanning for default JPA setup
Thanks @ayudovin. I've polished your contribution and fixed the Hibernate 5.2 problem as well. |
I wonder if it makes sense to provide a simpler boolean flag as user facing property to avoid Hibernate internals leaking into user application configuration? |
@odrotbohm there is not configuration exposed at all so I am not sure what you mean there. If you don't specify anything, we use the disabled scaner impl (which, I believe, matches your original report). |
Oh, and does it make sense to use the disabled scanner by default. I guess an average Boot user doesn’t expect any Hibernate-driven scanning to run in the first place anyway? |
Is that a question? If that is, you lost me as you created an issue to request that scanning to be disabled by default (unless I misunderstood it). If disabling the scanner is not 100% safe, we should revert this and clarify the scope of the issue you've created. |
Okay, maybe the changes view is messed up then. I see tests that set a pretty complicated property that directly configured the scanner. Given our experience with Hibernate those things change quite frequently so that I wondered whether something like |
I was just looking at what the changes tab provided on mobile view and that doesn’t seem to contain anything hinting at what default you chose. |
There is nothing in your request that indicated this should be configurable. We can introduce a property but that doesn't match the description of #15321. I've already indicated that if disabling the scanner in the context of a Spring Boot auto-configured app wasn't safe, I think the scope of the issue should be clarified (with a potential reopen). As for the "pretty complicated" property, it's just the standard Hibernate property with a prefix to help us grab it. |
Fine, thanks. |
this enhancement