|
I have many-to-many between two existing tables(Error and Attribute) with the joint table(Error_Attribute_Map) in database. I am trying to map them using domain classes. Problem I am facing is when I ask for Attribute from Error GORM query does not include Joint Table hence I dont get back any Attribute Objects for a given Error Object. Please let me know If I am missing any mapping.
Error domain class
|
|
Any suggestions / ideas?
|
|
In reply to this post by meena
A Grails many-to-many needs a hasMany on each side but one of them also needs a belongsTo to define the owning side. Ordinarily if you omit the belongsTo Grails complains at startup but it doesn't in this case; I'm assuming it's because as of 2.0 there is a real "errors" property (the validation Errors instance) in each domain class, so it's not considering this a proper many-to-many. If you change "errors" to "errs" you will see the startup message.
When trying to work with legacy database it's convenient to run 'grails schema-export' and look at the generated target/ddl.sql file. Keep tweaking the mappings and comparing the generated DDL to the real database until they're equivalent. Btw - you should remove the semicolons from your code, and also the "Long id" fields since Grails adds those for you. Burt
|
|
Hi burtbeckwith
Thankyou very much for your input. Yes u were very right replacing errors by other name did the trick for me. Thanks again, I was struggling for five days with this issue. Meena |
| Powered by Nabble | Edit this page |
