-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping a class with multiple inheritence
PostPosted: Tue Oct 12, 2004 1:50 pm 
Newbie

Joined: Wed Nov 12, 2003 3:45 pm
Posts: 8
Can anyone give a hibernate 2.1 example of how to map a class that implements two interfaces?

Provided below is how we're mapping a class that is implementing OrderableItem, but we're wanting to have Asset also implement BuilderAsset. We want to be able to use BuilderAsset in Hibernate just as we're able to use OrderableItem.

Do we have to include Asset as a joined-subclass in both mapping files? Is there a better way or a simpler way that I'm missing?

If anyone can point me in the right direction, thank you!

<hibernate-mapping>
<class name="collective.order.OrderableItem">
<id name="id" unsaved-value="null">
<generator class="native" />
</id>

<joined-subclass name="collective.md.image.Asset" table="Asset">
<key column="id" />
<set name="assetGroups" table="AssetGroupAssignments" cascade="none" inverse="true" lazy="true">
<key column="assetId" />
<many-to-many class="collective.md.image.AssetGroup" column="groupId" />
</set>

<list name="assetHistory" cascade="all" lazy="true">
<key column="asset_id"/>
<index column="i"/>
<one-to-many class="collective.md.image.AssetHistory"/>
</list>
<property name="copyOnly" />
<property name="dateUpdated" />
<property name="dateAdded" />
<property name="dateFileCreated" />
<property name="dateFileModified" />
<property name="deleted" />
<property name="expirationDate" />
<map name="fields" table="TypedField" cascade="all" lazy="true">
<key column="assetId"/>
<index column="keyName" type="string"/>
<one-to-many class="collective.md.image.TypedField"/>
</map>
<property name="filename" not-null="true" />
<property name="filepathMac" />
<property name="filepathUNC" />
<property name="filesize" />
<property name="merlotClass" />
<many-to-one name="metadata" class="collective.asset.Metadata" column="metadataId" cascade="save-update" outer-join="false" />
<property name="previewPixelWidth" />
<property name="releaseDate" />
<property name="imageInfoInitialized" />
<property name="imageInfo" length="8000" />
</joined-subclass>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 11:08 am 
Newbie

Joined: Wed Oct 13, 2004 10:21 am
Posts: 4
Does that even work? The class element:
Quote:
<class name="collective.order.OrderableItem">

doesn't have a "table" attribute. Isn't that required for the hbm.xml to validate?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 2:31 pm 
Newbie

Joined: Tue Aug 24, 2004 5:33 am
Posts: 8
Location: Russia
As I see it, The question is meaningless.

A class implementing a set of interfaces have a flat structure. There are no any hierarchy. And there no any difference between this class mapping and the mapping of interface-less class with equivalent set of properties.

Suppose we have two inerfaces A and B mapped to different tables. There is some class C implementing both interfaces. I never tried such design, because I think the result to be unpredictable if we'll begin operating with C throw the Hibernate session (really result depends on implicit objects structure).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.