Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

many-one association

 
Akhil Maharaj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All ,

Book is associated with Publisher by many-one asociation

I am attaching Book.java ,Book.hbm.xml , Publisher.java , Publisher.hbm.xml.

Everything works OK. When I want to delete couple of rows in PUBLISHER , I am getting exception as they are referred in BOOK table.

Can anybody share ideas if I want to delete all the BOOK objects when the associated PUBLISHER is deleted ? ( Some thing like cascade=delete).
it might be obvious for some of you....

********** Publisher.java


********** Publisher.java ends here

********** Publisher.hbm.xml starts here


********** Publisher.hbm.xml ends here



************ Book.java starts here

************ Book.java ends here


************ Book.hbm.xml starts here

************ Book.hbm.xml ends here
 
Kuladip Yadav
Ranch Hand
Posts: 162
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Akhil,

You can just add set books into Publisher , like you have added chapters in books.
So add it in your Publisher.java and Publisher.hbm.xml

You will get your required result.
For more information Check This Link

Thanks
- Kuldeep
[ November 11, 2008: Message edited by: Kuldeep Yadav ]
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm also stuck with the same issue of cascade delete,can you guys tell me how you have modified the hbm.xml and relevant java file.?

--
Deepak Lal
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!