KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In order to achieve a foreign key column (no joinTable) when mapping a unidirectional OneToMany relationship, i follow the steps according to Grails (version 2.2.3) reference documentation, section 6.5.2.1 OneToMany mapping, which states With unidirectional associations the foreign key needs to be specified on the association itself. For example given a unidirectional OneToMany relationship between Person (replaced by One) and Address (replaced by Many), the following code will change the foreign key in the Many table class One { static hasMany = [manyCollection:Many] static mapping = { manyCollection(column:"ONE_ID") } } However, when i run One one = new One() one.addToManyCollection(new Many()) one.save() I get in the console insert into one (id, version) values (null, ?) insert into many (id, version) values (null, ?) insert into one_many (one_many_collection_id, many_id) values (?, ?) Notice Grails create a joinTable called one_many. So, my question: it is a bug or something else ? What should i do to get rid of the joinTable ? Even when i use something like class One { static hasMany = [manyCollection:Many] static mapping = { manyCollection(joinTable:false) } } as highlighted here , i get the same output
Tags (comma-separated)
Save Edits
Cancel