Hibernate: <component> v/s <subclass>

jaggernat
jaggernat used Ask the Experts™
on
hi guys

can anyone tell me what is the difference between <component> and <subclass>  in hibernate. I have a child class as a property inside parent class, so
i am using <component> tag to map the properties of a child object to the parent class table.
but in what scenarios do i use <subclass> tags?

any sugessions appreciated

thanks
J
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mick BarryJava Developer
Top Expert 2010

Commented:

Author

Commented:
>>><class name="Payment" table="PAYMENT">
    <id name="id" type="long" column="PAYMENT_ID">
        <generator class="native"/>
    </id>
    <discriminator column="PAYMENT_TYPE" type="string"/>
    <property name="amount" column="AMOUNT"/>
    ...
    <subclass name="CreditCardPayment" discriminator-value="CREDIT">
        ...
    </subclass>
    <subclass name="CashPayment" discriminator-value="CASH">
        ...
    </subclass>


In above code any idea what is <discriminator> used for?
Java Developer
Top Expert 2010
Commented:
it defines which column decides what subclass to create

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial