Issue Details (XML | Word | Printable)

Key: GRAILS-4158
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Graeme Rocher
Reporter: David Rosenstark
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Grails

Create more flexibility in one to one relationship (bidirectional)

Created: 01/Mar/09 04:38 AM   Updated: 23/Jul/09 08:28 AM   Resolved: 23/Jul/09 08:28 AM
Return to search
Component/s: Persistence
Affects Version/s: 1.1-RC2
Fix Version/s: 1.2-M2

Time Tracking:
Not Specified


 Description  « Hide

The current implementation of one to one bidirectional requires that the table with the FK in it be the parent. Perhaps this can be improved so that we can not have this requirement. A possible way to do this would be to have a keyword hasOne similar to hasMany so that one to one can work just like one To Many (since this works perfectly in the hasMany relationship).



Graeme Rocher added a comment - 23/Jul/09 08:28 AM

This can now be mapped with the below.

class Face {
    String name
    static hasOne = [nose:Nose]

}

class Nose {
    String shape
    Face face
}

In this case the foreign key will be stored in the "nose" table not the "face" table as before