-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Yet another stupid Interface question
PostPosted: Tue Feb 17, 2004 12:51 pm 
Beginner
Beginner

Joined: Fri Jan 02, 2004 7:07 pm
Posts: 35
I'm looking at the documentation for mapping implementations of an interface with joined-subclass (for the subclass-per-table stategy).

Code:
<class name="Payment" table="PAYMENT">
    <id name="id" type="long" column="PAYMENT_ID">
        <generator class="native"/>
    </id>
    <property name="amount" column="AMOUNT"/>
    ...
    <joined-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
        <key column="PAYMENT_ID"/>
        ...
    </subclass>
    <joined-subclass name="CashPayment" table="CASH_PAYMENT">
        <key column="PAYMENT_ID"/>
        ...
    </subclass>
    <joined-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
        <key column="PAYMENT_ID"/>
        ...
    </subclass>
</class>


Further down:



Quote:
For either of these two mapping strategies, a polymorphic association to Payment is mapped using <many-to-one>.


Code:
<many-to-one name="payment"
    column="PAYMENT"
    class="Payment"/>


So my understanding is that I add this mapping to every joined-subclass implementing class in the mapping document and I then add a getPayment() method to every Implementing class (of the Interface) so it can reference the Interface class?

I've tried this and everything executes OK but the column that I refer to in the many-to-one property 'column' is NULL every time I add an object of the Interface type.

My Interface type is also a member of a Collection of another object (on the many-valued end of a one-to-many relationship) but that should not really be an issue right?

I've read through all I can find on the forum about this but I'm still confused.

Damn! I really need that Hibernate in Action book :)

I use 2.1.1.

This is the mapping file if that helps:





Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class name="com.lehman.mis.model.CommissionProfile" table="COMMISSION_PROFILE">

        <id name="id" type="integer" column="ID">
                <generator class="identity"/>
        </id>

        <!-- A bi-drectional mapping. A CommissionProfile can't live without a Commission. -->
        <many-to-one name="parent" class="com.lehman.mis.model.Commission" column="PARENT_ID" not-null="true"/>

        <joined-subclass name="com.lehman.mis.model.RbCommissionProfile" table="RB_COMMISSION_PROFILE">
            <key column = "ID"/>

            <many-to-one name="commissionProfile" class="com.lehman.mis.model.CommissionProfile" column="COMMISSION_PROFILE"/>

            <property name="timeStamp" type="timestamp">
                <column name="TIMESTAMP" not-null="true"/>
            </property>

            <property name="comment" type="string">
                <column name="COMMENT"/>
            </property>

lots of properties follow....
</joined-subclass>
    </class>

</hibernate-mapping>


I'll post the classes also if needed...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 1:01 pm 
Beginner
Beginner

Joined: Fri Jan 02, 2004 7:07 pm
Posts: 35
I have a hunch I don't relly need that many-to-one mapping inside the joined-subclass...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.