-->
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: one-to-one mapping
PostPosted: Mon Jan 28, 2013 1:45 am 
Newbie

Joined: Wed Jan 23, 2013 7:00 am
Posts: 8
Hi,

i have created three tables as follows
1)create table customers_n(customer_id integer , customername varchar(30),order_no varchar(100), PRIMARY KEY (customer_id,order_no));
2)create table orders_n(orderid integer , order_no varchar(100),item_code varchar(100),customer_id integer,amount integer,PRIMARY KEY (customer_id,order_no,item_code),FOREIGN KEY(customer_id,order_no) REFERENCES customers_n(customer_id,order_no) );
3)create table item_master (item_code varchar(100),item_desc varchar(100),PRIMARY KEY (item_code),FOREIGN KEY (item_code) references orders_n(itemcode) );
one-many relationship between customers_n and orders_n , one-one relationship between orders_n and item_master
when i generated hbm.xml file iam getting one-many relationship but iam not getting one-one realationship in hbm.xml as follows:


<hibernate-mapping>
<class name="OrdersN" table="orders_n" catalog="relationships">
<composite-id name="id" class="OrdersNId">
<key-property name="customerId" type="int">
<column name="customer_id" />
</key-property>
<key-property name="orderNo" type="string">
<column name="order_no" length="100" />
</key-property>
<key-property name="itemCode" type="string">
<column name="item_code" length="100" />
</key-property>
</composite-id>
<many-to-one name="customersN" class="CustomersN" update="false" insert="false" fetch="select">
<column name="customer_id" not-null="true" />
<column name="order_no" length="100" not-null="true" />
</many-to-one>
<property name="orderid" type="java.lang.Integer">
<column name="orderid" />
</property>
<property name="amount" type="java.lang.Integer">
<column name="amount" />
</property>

<property name="itemDesc" type="string" >
</property>
</class>
</hibernate-mapping>
how to get one-one mapping


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.