|
Hi,
I have an *unidirectional* one-to-many relationship like this: class Group { static hasMany = [items: Item] } class Item { Group subgroup static constraints = { subgroup nullable: true } } def group = new Group().save() def item = new Item().save() group.addToItems(item) group.save() this is setting item.subgroup to group. But this is not my intention. Can I avoid addTo setting the back-reference? Thanks, Danilo --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On 20/07/2012 07:02, Danilo Tuler wrote:
> Can I avoid addTo setting the back-reference? I believe you can do this with static mappedBy = [items:null] on the Group side. Ian -- Ian Roberts | Department of Computer Science [hidden email] | University of Sheffield, UK --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Did not work...
2012/7/20 Ian Roberts <[hidden email]>: > On 20/07/2012 07:02, Danilo Tuler wrote: >> Can I avoid addTo setting the back-reference? > > I believe you can do this with > > static mappedBy = [items:null] > > on the Group side. > > Ian > > -- > Ian Roberts | Department of Computer Science > [hidden email] | University of Sheffield, UK > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On 20/07/2012 15:48, Danilo Tuler wrote:
> Did not work... Sorry, I was working from a memory of a past post about a similar situation, but I misremembered: http://grails.1312388.n4.nabble.com/grails-1-3-7-GORM-misinterpretation-of-nullable-reflective-many-to-one-relationship-possible-bug-tp4585805p4589361.html That suggests it should be mappedBy = [items:'null'] (i.e. the string n-u-l-l rather than null). Ian -- Ian Roberts | Department of Computer Science [hidden email] | University of Sheffield, UK --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
> http://grails.1312388.n4.nabble.com/grails-1-3-7-GORM-misinterpretation-of-nullable-reflective-many-to-one-relationship-possible-bug-tp4585805p4589361.html
> > That suggests it should be mappedBy = [items:'null'] (i.e. the string > n-u-l-l rather than null). No luck. I get this error: context.ContextLoader Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Non-existent mapping property [null] specified for property [items] in class [class Group] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Non-existent mapping property [null] specified for property [items] in class [class Group] ... 5 more --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
What if you implement your own addToItems method on Group?
On Fri, Jul 20, 2012 at 8:27 PM, Danilo Tuler <[hidden email]> wrote:
|
| Powered by Nabble | Edit this page |
