-->
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: How to one-to-one mapping with two column as key
PostPosted: Wed Jul 18, 2007 11:23 pm 
Newbie

Joined: Wed Jul 18, 2007 11:05 pm
Posts: 1
Good evening,

Here is my problem.

I need to relate two tables using two column.

Table A
id
domain
extension
status
flag

Table B
id
domain
extension
userid

I'm working on an existing database , where i dont have the privilege to modify the schema of the database. Dont even complain why the schema is created this way, cause we (me and my team mate) are already cursing throughout development due to horrendous schema design.

Anyway,
I need to relate both tables together, using "domain" and "extension".

Currently,
i am able to achieve by just using one column but completely lost in terms of using two columns.

Table A xml mapping
Code:
<id name="domainsid" type="int">
            <column name="domainsid" />
            <generator class="assigned" />
        </id>
      <property name="domain" type="string">
            <column name="domain" length="64" not-null="true">
                <comment></comment>
            </column>
        </property>
        <property name="extension" type="string">
            <column name="extension" length="25" not-null="true">
                <comment></comment>
            </column>
        </property>
(others are not included for brevity)


Table B xml mapping
Code:
     <id name="userid" type="int">
            <column name="userid" />
            <generator class="assigned" />
        </id>
        <property name="domain" type="string" insert="false" update="false">
            <column name="domain" length="64" not-null="true">
                <comment></comment>
            </column>
        </property>
        <property name="extension" type="string" >
            <column name="extension" length="25" not-null="true">
                <comment></comment>
            </column>
        </property>
       <many-to-one name="domainVO"
          class="DomainVO" property-ref="domain" column="domain"
          unique="false" not-found="ignore" lazy="proxy" outer-join="true"/>


This works, but when there is duplicate in "domain" column, it throws back an error stating there is more one row identifier, it's understood that values in the "domain" column will repeat but not with the same "extension". A "domain" and "extension" column makes up a key by itself.

Thanks guys for your help.


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.