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.