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
|