• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate 1-many insertion

 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ranchers,
i have 2 beans (employee,address)with the properties
Employee: empid,empname,empsal,address[Set] : pk: empid
Address : addid,empid,city,state pk: composite id (addid,empid)

and my hbm file



when i load it is giving me the data from two tables.
But when i insert it gives me the error.


Thangs in advance
Raj.
 
David Madouros
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you are saving your instance of Employee and not Address. Let us know if it doesn't work.
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am saving employee obj.
 
madhuchilipi reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u take empid in first table as primary keyj.
in second table we want to give the references to empid of second table.
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi madhu,
i tried but giving the same error.
can you provide some more help.

Raj.
 
David Madouros
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Raj,

This is what I probably should have said the first time...
I recreated your situation (see code below) and I only get the constraint violation if I save address without first saving employee. Could there be a difference in our implementations?


[ March 07, 2007: Message edited by: David Madouros ]
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi David,

I did as you showed.



But it is working fine when we load the data .
problam occurs when we insert the data . it is giving constraint
violation exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic