-->
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: [Mapping] Can we map a set on unique index multiple columns?
PostPosted: Thu Mar 06, 2008 2:30 pm 
Beginner
Beginner

Joined: Thu Nov 15, 2007 11:27 am
Posts: 34
Hello,

I need to map a link between two table where the foriegn key is not the primary key.

Table A (id, col1, col2, col3, col4) | (col1, col2, col3) is unique
Table B (id, col1, col2, col5) | (col1, col2) is unique

We got a link many to one between table A and B. I used "property-ref" and "properties" so I manage to defne the many to on relation.

For the other way relation, I define a "Set", but I can't find a good solution for the mapping on the key. It seems we can only used the primary key of the table. Is it true?
Code:
<hibernate-mapping>
    <class name="TableA" table="TABLE_A" schema="MySchema">
        <id name="id" type="java.lang.Integer">
            <column name="ID" />
            <generator class="increment" />
        </id>
      <properties name="sec_key" unique="true">
         <property name="col1" type="java.lang.Integer">
            <column name="COL1" not-null="true" />
         </property>
         <property name="col2" type="java.lang.Short">
            <column name="COL2" not-null="true" />
         </property>
      </properties>
...

Code:
<hibernate-mapping>
    <class name="TableB" table="TABLE_B" schema="MySchema">
        <id name="id" type="java.lang.Integer">
            <column name="ID" />
            <generator class="increment" />
        </id>
   <many-to-one name="tableA" class="TableA" update="false" insert="false" fetch="select" property-ref="sec_key">
      <column name="COL1" not-null="true" />
      <column name="COL2" not-null="true" />
   </many-to-one>

...


How to define the Set if Table A mapping?
Code:
       <set name="tableBs" inverse="true">
            <key ???????/>
            <one-to-many class="TableB" />
        </set>


Thanks.


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.