gsartori opened a new issue, #15736:
URL: https://github.com/apache/grails-core/issues/15736
### Expected Behavior
In Grails 7 (GORM 9 / Hibernate 5.6), join table column names generated for
hasMany associations do not consistently apply the configured NamingStrategy.
Instead of using the resolved table names, GORM uses the raw domain class
names, including prefixes such as `T`, when generating join table foreign key
columns.
Join table and foreign key columns should respect the naming strategy:
- book_id
- author_id
## Findings
- classToTableName() is invoked and works for entity tables
- Join table generation for hasMany associations does not consistently apply
NamingStrategy
- FK column names are derived from domain class names instead of physical
table names
## Impact
When domain classes use naming conventions (e.g. T* prefix), schema
generation becomes inconsistent:
- entity tables are correctly renamed
- join table FK columns still contain class prefixes
This forces the use of `static mapping` to create correct column names:
```
static mapping = {
team joinTable: [name: "book_authors", key: "author_id", column:
"book_id"]
}
```
### Actual Behaviour
Join tables are created, but FK columns are derived from the raw entity
class names, not the resolved table names:
- tbook_id
- tauthor_id
The 'T' prefix is not removed.
### Steps To Reproduce
1. Pull https://github.com/gsartori/issue-gorm-hasmany-fieldnames
2. ./gradlew bootRun
3. Look at the created tables in the database
- author_books
- book_authors
### Environment Information
Grails 7.x
GORM 9.x
Hibernate 5.6.x
JDK 17+
### Example Application
https://github.com/gsartori/issue-gorm-hasmany-fieldnames
### Version
7.1.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]