scottlollman opened a new issue, #14716:
URL: https://github.com/apache/grails-core/issues/14716

   ### Expected Behavior
   
    A domain class with a composite key should respect key column name 
specifications on joinTables.
   
   
   
   ### Actual Behaviour
   
   When setting mappings for a domain class with a composite key, the binder 
does not accept a list of column names and treats it as a string column name.  
There does not seem to be any valid configuration that will work.
   
   GrailsDomainBinder appears to convert a list or map to a string and tries to 
use that as a column name.  It produces the MappingException when comparing the 
joinTable key column count to the composite key column count.  
   
   The issue appears to start in `bindCollectionSecondPass`, around 450, after 
checking `hasJoinKeyMapping`.  That branch assumes a column name for a single 
long column is being defined.  It may also have issues if the primary key is 
not a long type column.  
   
   ### Steps To Reproduce
   
   1. Create a grails application using hibernate 5.  
   2. Add a domain class structured like this:
   ```class ExampleDomain {
     String a, b
     Collection<String> cList
   
     static mapping = {
       id composite:['a','b']
       cList(
         joinTable:[
           name:'example_domain_c_list',
           key:['a_col','b_col'],
           column:'c'
         ]
       )
     }
   }'''
   3. Run the application and get a crash
   MappingException: Foreign key (FK...example_domain [a_col, b_col])) must 
have same number of columns as the referenced primary key (example_domain [a,b])
   
   ### Environment Information
   
   - Operating System: MacOS 15.4.1
   - Java version: Corretto 11
   - GORM version 8.1.2
   - Grails version: 6.2.0
   
   ### Example Application
   
   _No response_
   
   ### Version
   
   6.2.0


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