Skip to content

beforeInsert(), beforeUpdate() or other GORM event methods not called on abstract base class in src/main/groovy #621

@mjcmatrix

Description

@mjcmatrix

With Grails 3.1.0RC1 and Hibernate:

beforeInsert(), beforeUpdate() and other GORM event methods are not called on a domain abstract base class declared in src/main/groovy (i.e. the Grails equivalent of a JPA MappedSuperclass).

These methods were called, if present, in the same context in Grails 2.4.

One typical use case for such an abstract base class is an Audit or other common base class for entities, where fields such as dateCreated and createdBy will be nullable: false and require beforeInsert() and beforeUpdate() implementations to set the initial value.

There is a likely a workaround for this which I am about to test: Implementing a GORM Event listener by subclassing org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener and calling the methods that do not get called explicitly for all domain classes that extend the base class.

Reference to related issue #620.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions