Hi,
Suppose I have inheritance hierarchy SuperClass is Payment, Subclass is CreditPayment,CashPayment.
And I query from hql "from Payment p". It will fetch the records from Payment, CreditPayment and CashPayment. But I want records from only Payments and not from it's subclasses. How to do that. I tried explicit polymorphism. But not working.
Suppose Payment has 1 record, CreditPayment has 2 records and CashPayment has 3 records with following inheritance hierarchy.
If I select using HQL " from Payment P ", I will get 6 records. But I do not want hibernate to use implicit polymorphism, I want hibernate to select from only Payment and not from CashPayment and CreditPayment. How do I do it. I tried Poymorphism="explicit" But I still get 6 records. Please help.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.test">
<class name="Payment" table="payment" polymorphism="explicit">
<id column="id" type="long" name="id">
<generator class="native" />
</id>
<discriminator column="payType" type="string"></discriminator>
<property name="amount" column="amount" type="double" />
<subclass name="CashPayment" discriminator-value="cash" >
<property name="testProperty" type="string"
column="testProperty" />
</subclass>
<subclass name="CreditPayment" discriminator-value="credit">
<property name="testProperty2" type="string"
column="testProperty2" />
</subclass>
</class>
</hibernate-mapping>