Grails

one-to-many can't create mapping for belongsTo with composite key

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.1-beta3
  • Component/s: Persistence
  • Labels:
    None
  • Environment:
    grails 1.0.3/linux

Description

A one-to-many relationship with a composite primary key in the parent is unable to construct the foreign key from the child to the parent

class Parent implements Serializable {
static mapping = { id composite:['col1', 'col2'] }
static hasMany = [ children : Child ]
String col1
String col2
}
class Child {
static belongsTo = [ parent : Parent ]
}

Starting the application returns the following error:

... nested exception is org.hibernate.MappingException: Foreign key (FK5A3F51C976A59A:child [parent_id])) must have same number of columns as the referenced primary key (parent [col1,col2]):
org.hibernate.MappingException: Foreign key (FK5A3F51C976A59A:child [parent_id])) must have same number of columns as the referenced primary key (parent [col1,col2])

Issue Links

Activity

Hide
Michael Walker added a comment -

I am getting this problem with 1.1-beta2 also. This is a major headache for me...

Show
Michael Walker added a comment - I am getting this problem with 1.1-beta2 also. This is a major headache for me...
Hide
Graeme Rocher added a comment -

Bulk closing bunch of resolved issues

Show
Graeme Rocher added a comment - Bulk closing bunch of resolved issues

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: