|
Graeme Rocher made changes - 20/Nov/08 07:07 AM
Graeme Rocher made changes - 28/Nov/08 08:22 AM
Graeme Rocher made changes - 18/Dec/08 05:33 AM
Fixed. Not this fix applies only to bidirectional one-to-ones. A unidirectional one-to-one is still mapped as a many-to-one by default. You can make it unique if you don't like this, which results in a true one-to-one: class Face {
Nose nose
static mapping = {
nose unique:true
}
}
Graeme Rocher made changes - 18/Dec/08 11:09 AM
I downloaded 1.1 RC1 and groovy 1.6 and create two classes: class Face { static mapping = {
nose unique:true
} class Nose { Face face String nostril1 String nostril2 } When i bring up the app, i still see two foreign key columns: In order to get the single column mapping you need to define an owner: class Face {
String eyes;
String mouth;
Nose nose
static mapping = { nose unique:true }
}
class Nose {
static belongsTo [face:Face] // THIS IS THE CHANGE
String nostril1
String nostril2
}
Sorry should have been clear on that in the issue Thanks, for the clarification. If i understand what you are saying (and i tested it and it works!), then this means that we in order to have the one FK, we are forced to have the cascade in this direction and not the reverse. In other words, if the FK were in Nose instead, then Face would need to belongTo Nose and cascading would be reversed. Or is there some way around this? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This feature is required because has_one associations meets often in Rails app. If we want to have possibility to seamlesly port applications to Grails, this is musthave feature