Configures discriminator behavior for sealed type hierarchies.
This annotation is used in three contexts:
- On a sealed interface: Required for Single-Table, optional for Joined
Table. Specifies the discriminator column name in the database table. If no column name is provided, defaults
to
"dtype"(consistent with the JPA convention). When omitted for Joined Table, Storm resolves the concrete type at query time via a CASE expression that checks which extension table has a matching row.Java:
@Discriminator // uses default column name "dtype" sealed interface Pet extends Entity<Integer> permits Cat, Dog {} @Discriminator(column = "pet_type") // uses custom column name sealed interface Pet extends Entity<Integer> permits Cat, Dog {}Kotlin:
@Discriminator // uses default column name "dtype" sealed interface Pet : Entity<Int> @Discriminator(column = "pet_type") // uses custom column name sealed interface Pet : Entity<Int> - On a concrete subtype: Optional. Specifies the discriminator value for this subtype.
Defaults to the simple class name for Single-Table/Joined patterns, or the resolved table name for
Polymorphic FK.
Java:
@Discriminator("LARGE_DOG") record Dog(@PK Integer id, String name, int weight) implements Pet {}Kotlin:
@Discriminator("LARGE_DOG") data class Dog(@PK val id: Int?, val name: String, val weight: Int) : Pet - On a foreign key field (Polymorphic FK): Optional. Customizes the discriminator
column name in the referencing entity's table. Defaults to
"{fieldName}_type".Java:
record Comment(@PK Integer id, String text, @FK @Discriminator(column = "content_type") Ref<Commentable> target ) implements Entity<Integer> {}Kotlin:
data class Comment(@PK val id: Int?, val text: String, @FK @Discriminator(column = "content_type") val target: Ref<Commentable> ) : Entity<Int>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe discriminator column types supported for sealed type hierarchies. -
Optional Element Summary
Optional Elements
-
Element Details
-
column
String columnThe discriminator column name.On sealed interfaces (Single-Table and optionally Joined Table): defaults to
"dtype"(consistent with the JPA convention). On FK fields (Polymorphic FK): defaults to"{fieldName}_type".- Default:
""
-
value
String valueThe discriminator value for a concrete subtype.Defaults to the simple class name for Single-Table and Joined patterns, or the resolved table name for Polymorphic FK.
When used as the sole attribute, can be specified as the annotation value:
@Discriminator("LARGE_DOG").- Default:
""
-
type
The discriminator column type. Only meaningful on the sealed interface (where it defines the column type). On subtypes and FK fields, this attribute is ignored.Defaults to
Discriminator.DiscriminatorType.STRING.- Default:
STRING
-