-->
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: Collection Mapping to Classes with Inheritence
PostPosted: Fri Jul 11, 2008 2:09 am 
Newbie

Joined: Fri Jun 13, 2008 5:37 am
Posts: 4
I have the following classes and I am using "table-per-subclass" mapping strategy (as defined in the documentation).

Class Hierarchy
============
IPayableFee (interface)
-> ClassFee (subclass inheriting IPayableFee)
-> OtherFee (subclass inheriting IPayableFee)

Database Tables
=============
PayableFee (PK: intIdPFee)
ClassFee (PK: intIdCFee. also an FK one-to-one linked to intIdPFee of PayableFee)
OtherFee (PK: intIdOFee. also an FK one-to-one linked to intIdPFee of PayableFee)

Hibernate Mapping document
====================
<class name="IPayableFee" table="PayableFee">

<id name="Id" column="intIdPFee" type="Int64">
<generator class="identity"/>
</id>

....other properties of IPayableFee


<joined-subclass name="ClassFee" table="ClassFee" >
<key column="intIdCFee"/>

....other properties of ClassFee
</joined-subclass>

<joined-subclass name="OtherFee" table="APAS_OtherFee" >
<key column="intIdOFee" />

....other properties of Other Fee
</joined-subclass>
</class>


Now, i have another class (PaymentAdvice) that want to contain a collection (IDictionary indexed by Id) of IPayableFee. So, i define the collecition mapping like this

<map name="PayableFees" cascade="none" >
<key column="intIdPFee" ></key>
<index column="intIdPFee" type="Int64"/>
<one-to-many class="IPayableFee" not-found="exception"/>
</map>

The Hibernate is throwing this error

Repeated column in mapping for collection: PaymentAdvice.PayableFees column: intIdPFee ...

I have read the documentation... It only specify how to do polymorphic association using many-to-one mapping. But, mine is a collection so i cannot use many-to-one and I have defined the mapping according to the guidelines in the collection mapping chapter... I dunno what's wrong. can anyone help me? thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 11, 2008 10:35 pm 
Newbie

Joined: Tue Mar 11, 2008 4:11 am
Posts: 3
may be same column couldn't be used for key column and index column? i think i had same issue before and i had to add new column for index column. but if the index in collection is not that important u can use bag where u don't need to use index column. but looks like index is important to u ;)


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.