Package st.orm

Annotation Interface Polymorphic


@Target(TYPE) @Retention(RUNTIME) public @interface Polymorphic
Specifies the inheritance strategy for a sealed entity hierarchy.

Place this annotation on a sealed interface that extends Entity to indicate that the hierarchy uses Joined Table inheritance. Without this annotation, sealed entity hierarchies default to Single-Table inheritance.

Java:


 @Polymorphic(JOINED)
 sealed interface Pet extends Entity<Integer> permits Cat, Dog {
     String name();
 }

 record Cat(@PK Integer id, String name, boolean indoor) implements Pet {}
 record Dog(@PK Integer id, String name, int weight) implements Pet {}
 

Kotlin:


 @Polymorphic(JOINED)
 sealed interface Pet : Entity<Int> {
     val name: String
 }

 data class Cat(@PK val id: Int?, val name: String, val indoor: Boolean) : Pet
 data class Dog(@PK val id: Int?, val name: String, val weight: Int) : Pet
 
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The inheritance strategies for sealed entity hierarchies.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The inheritance strategy.