Hibernate Subclass which has multiple discriminator values

前端 未结 2 1715
醉话见心
醉话见心 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
    

提交回复
热议问题