Hibernate Subclass which has multiple discriminator values

前端 未结 2 1716
醉话见心
醉话见心 2021-02-04 03:56

Hello I have a Subclass which needs to cover multiple Discriminator Values.

something like:

@DiscriminatorValue(value = \"ACT\",\"DNR\",\"ATT\" )

would d

相关标签:
2条回答
  • 2021-02-04 04:36

    You can use DiscriminatorFormula:

    // Base class
    @DiscriminatorFormula("case when value in ('ACT','DNR','ATT') then 1 
       when 'OTH' then 2 else 3 end")
    
    // Subclass 
    @DiscriminatorValue("1") // maps to ACT, DNR, ATT
    
    0 讨论(0)
  • 2021-02-04 05:00

    A subclass has exactly 1 discriminator value.

    You can add additional subclasses under the existing subclass for the extra discriminator values. Subclasses need not have additional properties or behavior.

    0 讨论(0)
提交回复
热议问题