In my project i'm using 26 classes..That means i used 26 tables to store that objects in DB.And my DB schema is some what complex..In one class i'm using multiple Object references..
For Ex: class Car { int id; Tyre tyre; Glass glass; ... }
Now i'm coming to Issue..,I created the object for Tyre below : Tyre mrf=new Tyre(); tyre.setName("MRF");
I'm using this tyre object reference in 4 classes..Ex Bus,Car,Van,Cycle. For Ex: bus1.setTyre(mrf); car1.setTyre(mrf); van1.setTyre(mrf); cycle1.setTyre(mrf);
Now i tend to delete this mrf object..before i delete this mrf object i must have to nullify the reference of mrf in all table's where i use this..To implement this i found 2 ways..
1--> To create relation ship between the objects.via that association i can access and nullify.But RELATIONSHIP between the Object is unwanted to business logic and also too difficult to implement.
2-->So i tried other way.., i use query to access that object using the id in all the tables where are all i'm using that object reference and nullify manually..Iterate in query results and set null to all reference..For Ex : car1.setTyre(null);...
This is very small example..,but in project i nearly use one object reference in more than 5 classes..So i feel very tough to implement second method also.. Is there any way to easily handle this problem..???
Thank's in Advance...
|