gorm - Grails addTo* with result of database -


why code not work fine?

def classeinstrumento = classeinstrumentoservice.getclasseinstrumento("value")  def instrumentoinstance = new instrumento().addtoclasseinstrumento(classeinstrumento) 

i receive error message on console:

no signature of method: package.instrumento.addtoclasseinstrumento() applicable argument types: (package.classeinstrumento) values: [package.classeinstrumento : 5] 

and domains structure

class classeinstrumento {     static hasmany = instrumentos: instrumento }  class instrumento {      classeinstrumento idclasseinstrumento      static hasmany =  [ativodefs: ativodef,                       futurodefs: futurodef,                       operacaodefs: operacaodef]      static belongsto = [classeinstrumento] } 

so expected worked, didn't :(

thanks replies!

instrumento belongsto classeinstrumento.

which means classeinstrumento parent , instrumento child of classeinstrumento (signified hasmany in classeinstrumento)

addto* used parent towards child means

"add parent foreign_key reference child", means

classeinstrumento.addtoinstrumentos(new instrumento())

will work , not former approach use.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -