« Return to Thread: Strange behavior on bidirectional one-to-one relations

Re: Strange behavior on bidirectional one-to-one relations

by Robert B :: Rate this Message:

Reply to Author | View in Thread


stefano gualdi wrote:
If i create a new Folder object with this code:

def spec = new FolderSpec(details:'dummy')
def folder = new Folder(name:'MainFolder')
folder.specification = spec
folder.save(flush:true)

the reference 'folder' on FolderSpec remains null. While, using this:

def spec = new FolderSpec(details:'dummy')
def folder = new Folder(name:'MainFolder', specification: spec)
folder.save(flush:true)

everything works as expected.
I thought that according to the documentation, you're supposed to create the objects as follows, to get the cascading behavior:

def folder = new Folder(specification:new FolderSpec(details:'dummy'))
folder.save(flush:true)

--Rob

 « Return to Thread: Strange behavior on bidirectional one-to-one relations