aspose file tools
The moose likes Object Relational Mapping and the fly likes deleting entity with many-to-one association Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "deleting entity with many-to-one association" Watch "deleting entity with many-to-one association" New topic
Author

deleting entity with many-to-one association

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
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

Joined: Aug 26, 2006
Posts: 4967

Why not just get the phoneNumber, and then call a delete on it? That would delete the object itself.

-Cameron McKenzie


Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: deleting entity with many-to-one association
 
Similar Threads
Native contact list
Making multiple files from single file
Input From Console
Enthuware's Mock Exams and My telephone number
Array? Arraylist?