discriminator
目的 Purpose
Customizes the discriminator column used in table-per-subclass inheritance mapping.使用例 Examples
class Content { … }
class PodCast extends Content { … static mapping = { discriminator "audio" } }
詳細 Description
Usage:
使用方法: discriminator(string/map)
Usage:
discriminator(string/map)
引数: Arguments:
column
(optional) - The column name to store the discriminatorvalue
- The value to use for the discriminatorformula
(optional) - an SQL expression that is executed to evaluate the type of class. Use this orcolumn
but not bothtype
(optional defaults to string) - the Hibernate type, used for the where clause condition to know if it needs to wrap it with '
discriminator
method to customize what's stored:class Content { … }
class PodCast extends Content { … static mapping = { discriminator "audio" } }
class Content { … static mapping = { discriminator column: "content_type" } }
class PodCast extends Content { … static mapping = { discriminator value: "audio" } }
class Content { … static mapping = { discriminator value: "1", type: "integer", formula: "case when CLASS_TYPE in ('a', 'b', 'c') then 0 else 1 end", } }
class PodCast extends Content { … static mapping = { discriminator value: "0" } }