Search code examples
hibernategrailsgrails-orm

GORM envers @NotAudited one-to-many relationship Not persisted


In my Grails (2.4.3) project I'm trying to use Hibernate Envers directly without the plugin. Everything works fine as long as the domains don't have a relationship. I have a very common scenario where one Audited class has a direct association to a Not Audited Class.

Referring to GORM, Envers and @NotAudited relationships or adding annotations to hasMany-relation I got the auditing on the main class to work but then realised the associated entity is not persisted. I tried all the combinations in the above referred link but did not help. Here's a snippet of my Code:

@Audited
class Foo{
  Bar bar
  ...

  @NotAudited
  def getBar(){bar}

}

class Bar{
   ...
 }

Any help is much appreciated.


Solution

  • Change the return type of getBar from def to Bar.