-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Provide more details about overriding SpringPhysicalNamingStrategy's case insensitive flag #24045
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
Comments
SpringPhysicalNamingStrategy
problem when 2 entities own the same embeddable
Unfortunately, I cannot reproduce the problem that you have described. A minimal application with the three entities above starts successfully. Perhaps there's something more that's required to trigger the problem? If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. |
Sure, here is a zip file with a simple project. |
Thanks for the sample. The two different physical naming strategies produce the following identifiers:
The difference with Spring Boot's strategy is that the identifiers are all in lower-case. This is described in the reference documentation:
As your schema requires mixed-case identifiers, you can override the case sensitivity flag by declaring the following bean: @Bean
PhysicalNamingStrategy physicalNamingStrategy() {
return new SpringPhysicalNamingStrategy() {
@Override
protected boolean isCaseInsensitive(JdbcEnvironment jdbcEnvironment) {
return false;
}
};
} I think it would be useful if the documentation showed how to "override that flag if your schema requires it". We could include the example |
Thanks for the explanation, Any chance to configure this boolean through application.properties (something like |
Thanks for the suggestion. Unfortunately, I think that would be rather confusing as it would only work when using the default strategy. In other words, the following configuration would ignore the proposed property:
|
I don't think it is a problem if this
It is then obvious that My concern is about the developer who wants to use spring boot defaults ( |
Thanks again for the suggestion but we don't want to add a property for this. It's not a particularly common need and, no matter what the properties are called, I don't think it'll be possible to avoid the confusion caused by one property disabling another. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
SpringPhysicalNamingStrategy
(applied by defaut by spring boot) does not work in this case.error (when
EntityManagerFactory
is created) : org.hibernate.MappingException: Repeated column in mapping for collection: Book.comments column: book_id@Parent
cannot be used, becauseuser
is not a parent if comments are accessed from theBook
, andbook
is not a parent if comments are accessed from theUser
.Removing relations in
Comment
solve the problem, setting the naming strategies (both physical and implicit) to hibernate default also solve the problem :I don't know if this mapping is officially supported by Hibernate, but if Hibernate default strategy works, it could also work with
SpringPhysicalNamingStrategy
.The text was updated successfully, but these errors were encountered: