grailsgrails-2.0discriminator

In Grails, how do I get the discriminator value?


I have a class like this:

class Apple extends Fruit {
    static mapping = {
        discriminator "AppleType"
    }
}

Is there any way to get this discriminator value in the controller/view?


Solution

  • You can check the mapping of your domain class with the Mapping class. Example:

    def mapping = GrailsDomainBinder.getMapping(Apple)
    println mapping.discriminator