DISABILITARE ADBLOCK

ADBlock sta bloccando alcuni contenuti del sito

ADBlock errore

Changing the inheritance strategy in branches of the class hierarchy via JPA annotations

FONTE PRINCIPALE: https://stackoverflow.com/questions/1825676

DOMANDA COMPLETA

SOLUZIONE

Well, if you read the "Inheritance" chapter of Hibernate documentation a little further :-) you'll see that the example given for mixing table-per-hierarchy and table-per-subclass strategies is in reality nothing more than table-per-hierarchy with secondary tables thrown in:


    
        
    
    
    
    ...
    
        
            
            ...
        
    
    
        ...
    

You can do the same using @SecondaryTable annotation:

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="PAYMENT_TYPE")
@DiscriminatorValue("PAYMENT")
public class Payment { ... }

@Entity
@DiscriminatorValue("CREDIT")
@SecondaryTable(name="CREDIT_PAYMENT", pkJoinColumns={
    @PrimaryKeyJoinColumn(name="payment_id", referencedColumnName="id")
)
public class CreditCardPayment extends Payment { ... }

@Entity
@DiscriminatorValue("CASH")
public class CashPayment extends Payment { ... }

NON SEI SODDISFATTO ???

FONTI UTILI

StackOverflow