-->
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 a table join
PostPosted: Mon Jun 16, 2008 1:55 pm 
Newbie

Joined: Thu Jun 12, 2008 10:52 am
Posts: 16
Hello.
I have problems writing my mapping file. Here is my situation :
a table T_CONTRACT and a table T_CLIENT. T_CONTRACT is containing an id of T_CLIENT (representing the subsriber).
I would like to make a join between those 2 table so that i can get something like
Code:
Contract ct = ContractDAO.findById(1);
Client cl = ct.getFkSubscriber();

so far, i get to write this :
Contract.hbm.xml
Code:
<hibernate-mapping package="dao.person">
    <class name="Contract" table="contract">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="identity" />
        </id>
        <property name="idSubscriber" type="int">
            <column name="ID_CLIENT" not-null="true" />
        </property>       
     
        <join table="CLIENT" inverse="true" optional="true">
           <key column="ID" unique="true"/>
           <many-to-one name="fkSubscriber" column="ID_CLIENT"
                class="dao.client.Client" not-null="true" unique="true"/>
        </join>
    </class>
</hibernate-mapping>

Client.hbm.xml
Code:
<hibernate-mapping package="dao.client">
    <class name="Cient" table="client">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="identity" />
        </id>
     ...
    </class>
</hibernate-mapping>

But it doesn't work at all (a sql syntax exception is raised)
Can someone help me please ?


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.