These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to Avoid Unwanted relationship b/w Objects..
PostPosted: Tue May 24, 2011 7:09 am 
Newbie

Joined: Thu Nov 11, 2010 5:45 am
Posts: 4
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.