-->
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.  [ 1 post ] 
Author Message
 Post subject: collection mapping
PostPosted: Tue May 17, 2005 2:16 pm 
Newbie

Joined: Tue May 17, 2005 1:57 pm
Posts: 1
Hi All,
I am getting a following error when trying to map hibernate collection:
Foreign key (media_group [media_owner_id])) must have same number of columns as the referenced primary key (Overview [prop_id,type_id,locale_code])

Is it possible to create such a mapping where only one primary key would be used for mapping one-to-many relationship through a config file instead implementing onLoad method from within POJO class? If so, how would I do it based on Hibernate mapping below. This involves hard coding some of the values and I would rather do it in the config file if possible.

The reason application requires such a mapping is because of generic database media framework design where media can be attached to any table identified by table name and primary key.

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

<hibernate-mapping>
<class name="Overview" table="overview" mutable="false">
<cache usage="read-only"/>

<composite-id>
<key-property name="propertyId" column="property_id" />
<key-property name="typeId" column="type_id" />
<key-property name="lang" column="locale_code" />
</composite-id>

<property name="title" column="title_name" />

<bag name="mediaList" where="media_owner_type_name='Overview'">
<key column="media_id"/>
<one-to-many class="Media" />
</bag>
</class>

<class name="Media" table="media" mutable="false">
<cache usage="read-only"/>

<composite-id>
<key-property name="ownerId" column="media_owner_id" />
<key-property name="ownerTypeId" column="media_owner_type_cd" />
<key-property name="mediaId" column="media_id"/>
</composite-id>

<property name="mediaName" column="media_name"/>
</class>
</hibernate-mapping>

Any advices or suggestions will be appriciated.

Thanks,
Dmitriy Frolov


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

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.