-->
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.  [ 6 posts ] 
Author Message
 Post subject: repeated columns workaround?
PostPosted: Fri Sep 12, 2003 11:07 am 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
I get
net.sf.hibernate.MappingException: Repeated column in mapping for collection: co
m.studentuniverse.farefilter.persistent.Fares.priceCostCalc column: prcolo_id
at net.sf.hibernate.collection.CollectionPersister.checkColumnDuplicatio
n(CollectionPersister.java:838)

for the following mapping. Is there a way to let it use a column for more than one entry (or did I miss what the real problem is?)


Code:
        <many-to-one
            name="priceCostLookup"
            class="PriceCostLookup"
            cascade="none"
            outer-join="auto"
            update="false"
            insert="false"
            column="prcolo_id"
        />

        <set
            name="priceCostCalc"
            table="price_cost"
            lazy="false"
            inverse="false"
            cascade="none"
            sort="unsorted"
            order-by="prcolo_id,pricos_calc_order"
        >
              <key  column="prcolo_id"/>

              <many-to-many  class="PriceCost" column="prcolo_id"/>
        </set>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 11:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
How is it semantically correct to have an association table with just one column!?

This makes it a one-to-one association!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 11:50 am 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
I think I'm just way off and have to figure this out more.

What I have is table A with prcolo_id, and table B also with this id. Table B can have n number of records, so it sounds like a many to one.

I get confused as to what tables the "column" attributes refer to. What I need to figure out is how to tell it use table a column as the key, and get the collection from table b's corresponding column.

I tried one to many but it won't take a column attribute, I think it's only assuming using the primary key for my table B, and I can't use something different, or figure out how to specify that yet.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 11:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You do NOT need to specify the primary key in a one-to-many mapping! Hibernate is not stupid. It knows what the damn primary key column of a class is!


The rules are quite simple:

The <joined-subclass>, <class>, <set>, <list>, etc all define a table attribute. Any column names that appear inside one of these elements refers to _that_table_ (and no other table!)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 12:31 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
I am talking about this very restriction, if I understand it.

If I map class A to B one to many, the reference back to A must be A's ID, nothing else, correct?

Say A is a customer, and B are invoices. It makes sense the B will have a key for customer number.

But if A also has a messageID, and C is a message table (X lines of message for a messageID). Is it possible for me to make a one to many mapping that says a.messageID to c.messageID to get a collection of the messages for a customer?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 5:19 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
after looking some more, what I needed was a many to many, but without the interim table, which hibernate doesn't do. So I'll load in this collection via a joined query, which should solve it well enough.
Legacy data!


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