Mehrere abstrakte Klassen in JPA mit dem Inheritancetype.Single_table

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Mehrere abstrakte Klassen in JPA mit dem Inheritancetype.Single_table

by Anonymous » 14 Feb 2025, 14:25

Ich habe: < /p>

Code: Select all

@Entity(name="products")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="product_type",
discriminatorType = DiscriminatorType.INTEGER)
public abstract class Product {
// ...
}
< /code>
und < /p>
@Entity
@DiscriminatorValue("1")
public class Book extends Product {
// ...
}
< /code>
@Entity
@DiscriminatorValue("2")
public class EBook extends Product {
// ...
}
Jetzt möchte ich ein weiteres Abstract @Entity hinzufügen, um die Duplikation der allgemeinen Spalten und Methoden nur mit digitalen Produkten zu verhindern:

Code: Select all

@Entity
public abstract class DigitalProduct extends Product {
// ...
}
und Änderung der übergeordneten E-Book dazu:

Code: Select all

@Entity
@DiscriminatorValue("2")
public class EBook extends DigitalProduct {
// ...
}
Muss ich das DigitalProduct mit der @MappedSuperClass oder Single @Entity markieren?>

Top