Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deleting entity with many-to-one association

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two java classes Contact.java and PhoneNumber.java

Contact has a many-to-one relationship with PhoneNumber.

My question is if the user deletes the phone number from UI it should be delete from database. To achive this i am doing

contact.setPhoneNumber(null);

this code is deleting the phone number reference from contact but not deleting the record from the phone number table. How to achive this?

Thanks,
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just get the phoneNumber, and then call a delete on it? That would delete the object itself.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic