I have problem with assiciations for the following relations:
a person can purchase many items.
so records in purchase table can be like following:
person1, item1, qty,amt, time
person1,item2,qty,amt,time
.....
CREATE TABLE person (
person_id bigint(10) NOT NULL,
person_name varchar(50) default NULL
PRIMARY KEY (person_id)
)
CREATE TABLE item (
item_id bigint(10) default NULL,
item_name varchar(100) default NULL,
item_price double(10,2) default NULL )
CREATE TABLE purchase (
purchase_id bigint(10) NOT NULL default '0',
person_id bigint(10) NOT NULL default '0', item_id bigint(10) default NULL, quantity int(10) default NULL, amount double(10,2) default NULL, date_purchase datetime default NULL PRIMARY KEY (`purchase_id`)
)
i need to insert records into the purchase table and i need to retriview the information from the table. Please suggest me key mappings in hbm files.
i am stuck with creating hbms. Please help me in understanding this scenario.
Thanks in advance,
_________________ -Naresh
|