-
Notifications
You must be signed in to change notification settings - Fork 360
@Table Annotation is not honoured when joining on tables other than the aggregate root #1147
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
Labels
Milestone
Comments
This behaviour is actually intended this way, and probably quite some users probably depend on it by now. |
schauder
added a commit
that referenced
this issue
Sep 7, 2022
The default version is the behaviour that existed so far: The back reference is the table name as generated by the `NamingStrategy` without taking `@Table` annotations into account. The new alternative is to take `@Table` into account. The behaviour can be configured by setting the `foreignKeyNaming` property on the `RelationalMappingContext`. Closes #1161 Closes #1147
mp911de
pushed a commit
that referenced
this issue
Oct 5, 2022
The default version is the behavior that existed so far: The back reference is the table name as generated by the `NamingStrategy` without taking `@Table` annotations into account. The new alternative is to take `@Table` into account. The behavior can be configured by setting the `foreignKeyNaming` property on the `RelationalMappingContext`. Closes #1161 Closes #1147
mp911de
added a commit
that referenced
this issue
Oct 7, 2022
Do not expose setForeignKeyNaming methods on NamingStrategy to make less assumptions about how a naming strategy gets implemented. Provide getRequiredLeafEntity method on PersistentPropertyPathExtension to reduce null and state assertion checks. Refine getTableName/getQualifiedTableName approach to reduce API surface and avoid deprecations. See #1147 Original pull request: #1324.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Uh oh!
There was an error while loading. Please reload this page.
Hi, I ran into a problem with a
CrudRepository
and aggregates that contain one-to-many relations and were annotated with@Table
. Consider this example:with the following schema:
Now if I execute the following test (
BaseTestConfiguration
just initialises a connection to a Postgres database).it throws this error:
To me it looks like the
@Table
annotation is not honoured. Once I renameAuthorRecord
toAuthor
and drop the Annotation everything works fine. (Switching records to classes doesn't change the result.)During debugging I stumbled upon
org.springframework.data.relational.core.mapping.NamingStrategy#getTableName
, were the table name is derived from the type. I assume the problem could be fixed by looking for the annotation before defaulting totype.getSimpleName()
. I'm happy to try to submit a fix for it if necessary.pom.xml
The text was updated successfully, but these errors were encountered: