I was trying to use "Table per subclass" to map my three entities. These entities are
BillingDetails - Base class
CreditCardBilling - derived from BillingDetails
BankAccountBilling - derived from BillingDetails
I am getting the following exception
java.lang.ExceptionInInitializerError
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.ns.model.BillingDetails.id
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
Here is BillingDetails
Code:
public abstract class BillingDetails {
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
Here is the mapping file
Code:
<hibernate-mapping package="com.ns.model">
<class
name="BillingDetails"
abstract="true"
table="BILLING_DETAILS">
<id name="id"
column="BILLING_DETAILS_ID" type="long">
<generator class="native"/>
</id>
<property name="ownerName" column="OWNER" type="string"/>
<joined-subclass name="CreditCardBilling" table="CREDIT_CARD_BILLING">
<key column="CREDIT_CARD_NO"/>
<property name="expMonth" column="EXP_MONTH"/>
<property name="expYear" column="EXP_YEAR"/>
</joined-subclass>
<joined-subclass name="BankAccountBilling" table="BANK_ACCOUNT_BILLING">
<key column="ACCOUNT_NO"/>
<property name="bankName" column="BANK_NAME"/>
</joined-subclass>
</class>
</hibernate-mapping>
Any ideas why I am getting the IllegalArgumentException
regards,
Nirvan