0

I have Parent and Child class which has one to many mapping and I want to log Save action on both classes but at the time of saving log parent object is null in child class but it works fine for Parent class log

Here is my AuditLog, Parent and Child class

class AuditLog{
    String objectNameType = null;

 def onSave = { newMap ->
  String objectName = newMap[objectNameType]; // here I am getting null for child class save
   //code for storing logs
  }
}

class Parent extends AuditLog{
    String name;
    List child = new ArrayList()
    static hasMany = [ child:Child ]
    String objectNameType = name;

    public String toString(){
        return name;
    }
}

class child extends AuditLog{
    String childName;
    static belongsTo =[ parent : Parent];   
    String objectNameType = parent;

    public String toString(){
        return childName;
    }
}

I am using Grails 1.3.7 version and audit-logging 0.5.5

Any lead will be appreciated.

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Manish
  • 1
  • 1

1 Answers1

0

In Controller when I tried to access child.parent I am getting it as null. So I set it manually by iterating over child and it resolves my issue.

Manish
  • 1
  • 1