views:

67

answers:

0

Hi, this is actually connected to an earlier question of mine here.

Anyway, I have 3 domains that look like this:

class A {
  ...
  static hasMany = [ b : B ]
  ...
}

class B {
  ...
  static belongsTo = [ a : A ]
  static hasMany = [ c : C ]
  ...
}

class C {
  ...
  static belongsTo = [ b : B ]
  ...
}

In my GSP page, I call an action in the Controller via a remote function in a javascript block (I'm using Dojo so I'm passing data to be saved this way... it's not a form per se so I use JSON for now to pass the data to the Controller). Let's say, I'm calling something like this:

def someAction = {
   def jsonArr = [parse the JSON here]
   def tmpA = A.get(params.id)
   ...
   def tmpB = new B()
   b.someParam = jsonArr.someParam
   ...
   def tmpC = new C()
   tmpC.cParam = jsonArr.cParam

   tmpB.addToC(tmpC)
   tmpB.save(flush: true) //this may or may not be here but I'm adding it for the sake of completeness

   tmpA.addToB(tmpB)
   tmpA.save(flush: true)

   // NOTE: If I check here via println or whatnot, tmpA has a tmpB which has a tmpC... in other words, the data got saved. It's also in the DB.
   redirect(action: 'order' ...)
}

Then comes the fun part. Here's the webflow sample:

def orderFlow = {
   ...
   someStateIShouldEndUpIn {
      on("next") { // or on previous... doesn't matter
         def anId = params.id
         def currA = A.get(anId) // this does NOT return a null value
         def testB = currA.b // this DOES return a null value
      }.to("somePage")
      ...
   }
   ...
}

Any ideas on why this happens? Moreover, when I dump the data of currA, b=null... instead of b=[] or b=[contents of tmpB].

Any help would be seriously appreciated... been at this for a couple of days now...

Thanks!