MappedSuperclass Alternatives in Grails 2.0

The problem is the same as in the question older than SO , but the solution no longer works for Grails 2.0 - the abstract domain class is not processed as @MappedSuperclass, but its own table was always stored in it. If I move it outside of the grails-app / domain, it doesn't work at all.

So, is there a way to have an abstract superclass (or even better mixin) that will behave like @MappedSuperclass (without creating your own table with a common identifier and common fields)?

+4
source share
1 answer

we had the same problem and solved it with grails 2.2.1 (and not grails 2.0) as follows:

created an abstract superclass in src / groovy:

abstract class Auditable { Date dateCreated Date lastUpdated static constraints = { dateCreated(display:false) lastUpdated(display:false) } } 

created a specific class "Parcel" under grails-app / domain:

 class Parcel extends Auditable { ... } 

To solve this type of mapping, you should use Grails 2.1 or the latest version of Grails 2.2.3 instead of 2.0.x.

+2
source

Source: https://habr.com/ru/post/1401551/


All Articles