gsartori opened a new pull request, #16028:
URL: https://github.com/apache/grails-core/pull/16028

   ## Description
   
   Fixes [#15736](https://github.com/apache/grails-core/issues/15736).
   
   GORM previously generated default `hasMany` join-table foreign-key columns 
from the associated domain class name. This produced inconsistent names when 
the entity’s effective table name differed because of a custom Hibernate 
`PhysicalNamingStrategy` or an explicit table mapping.
   
   Join-table foreign-key prefixes are now derived from 
`GrailsHibernatePersistentEntity#getTableName(...)`, which resolves explicit 
mappings first and otherwise applies the configured naming strategy.
   
   Examples covered by regression tests:
   
   - `HTMPBook` transformed by a naming strategy to table `book` produces 
`book_id`.
   - `Book` explicitly mapped to table `htmp_book` produces `htmp_book_id`.
   
   The same table-name resolution is used by association join-table naming 
while preserving the existing behavior for basic and enum collections. Explicit 
join-table column mappings continue to take precedence.
   
   The custom naming strategy documentation now explains its effect on 
join-table foreign-key columns and warns that existing applications may require 
a schema migration or explicit column configuration.
   
   ## Contributor Checklist
   
   ### Issue and Scope
   
   - [ ] This PR is linked to an existing issue that has been **acknowledged or 
approved** by the project team. The PR fixes 
[#15736](https://github.com/apache/grails-core/issues/15736), but its approval 
status has not been independently verified.
   - [x] This PR addresses the **complete scope** of the linked issue.
   - [x] This PR contains a **single, focused change**.
   - [x] This PR targets the `8.0.x` major release branch.
   
   ### Code Quality
   
   - [x] I have added regression tests covering both custom physical naming and 
explicit entity table mappings.
   - [ ] I have not run the complete `./gradlew build --rerun-tasks`.
   - [ ] I have not run the complete `./gradlew codeStyle`.
   - [x] The targeted test was run successfully:
   
     ```text
     ./gradlew :grails-data-hibernate7-core:test \
       --tests 
"org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernateToManyPropertySpec"
 \
       --rerun-tasks
     ```
   
     Result: 47 tests passed, 0 failures, 0 skipped.
   
   - [x] This PR does not contain mass reformatting, style-only changes, or 
large-scale refactoring.
   - [x] Generative AI tooling was used with a quality model, and the resulting 
changes were reviewed and tested.
   
   ### Licensing and Attribution
   
   - [x] All changes are provided under the Apache License 2.0. No new source 
files were introduced; modified files retain their existing Apache license 
headers.
   - [ ] I have the necessary rights to submit this contribution and confirm it 
is my own original work.
   - [ ] I have followed the Apache Software Foundation’s policy on generative 
tooling and properly attributed its use.
   
   ### Documentation
   
   - [x] The custom naming strategy documentation explains how resolved table 
names affect join-table foreign-key columns.
   - [x] This is a bug fix rather than a new feature, so no **What’s New** 
update is required.
   - [ ] The documentation contains a schema-migration warning, but the 
corresponding **Upgrade Notes** have not been updated.
   - [x] This description explains what changed and why.


-- 
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]

Reply via email to