Hello there! I'm trying to reproduce the examples from caveat, but when I try to map a table per class hierarchy:
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name = "BILLING_DETAILS_TYPE",
discriminatorType = DiscriminatorType.STRING
)
@Table(name="BILLING_DETAILS")
public abstract class BillingDetails {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
@Entity
@DiscriminatorValue("CC")
public class CreditCard extends BillingDetails {
But when I try to open my session factory on hibernate view, I get the following error:
Code:
org.hibernate.console.HibernateConsoleRuntimeException: Could not create JPA based Configuration
Could not create JPA based Configuration
<No message>
java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException: <no message>
java.lang.reflect.InvocationTargetException
javax.persistence.PersistenceException: org.hibernate.AnnotationException: Cannot find the expected secondary table: no CREDIT_CARD available for org.acme.auction.model.CreditCard
org.hibernate.AnnotationException: Cannot find the expected secondary table: no CREDIT_CARD available for org.acme.auction.model.CreditCard
org.hibernate.AnnotationException: Cannot find the expected secondary table: no CREDIT_CARD available for org.acme.auction.model.CreditCard
Cannot find the expected secondary table: no CREDIT_CARD available for org.acme.auction.model.CreditCard
Now, according to the spec I should not need the secondary table annotation on my descendant class right? Checking the code from the app it does declare an @SecondaryTable, but not at the book, or other sources. Can't figure out why does Hibernate would need a SecondaryTable on a strategy mapped to use just a single table?