Несколько абстрактных классов в JPA с inheritancetype.single_tableJAVA

Программисты JAVA общаются здесь
Anonymous
Несколько абстрактных классов в JPA с inheritancetype.single_table

Сообщение Anonymous »

У меня есть: < /p>

Код: Выделить всё

@Entity(name="products")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="product_type",
discriminatorType = DiscriminatorType.INTEGER)
public abstract class Product {
// ...
}
< /code>
и < /p>
@Entity
@DiscriminatorValue("1")
public class Book extends Product {
// ...
}
< /code>
@Entity
@DiscriminatorValue("2")
public class EBook extends Product {
// ...
}
Теперь я хочу добавить еще один абстрактный @Entity , чтобы выявить общие столбцы и методы, связанные только с цифровыми продуктами:

Код: Выделить всё

@Entity
public abstract class DigitalProduct extends Product {
// ...
}
и изменить родитель электронной книги на нее:

Код: Выделить всё

@Entity
@DiscriminatorValue("2")
public class EBook extends DigitalProduct {
// ...
}
мне нужно отметить DigitalProduct с помощью @mappedsuperclass или Single @entity будет достаточно?


Подробнее здесь: https://stackoverflow.com/questions/794 ... ngle-table

Вернуться в «JAVA»