• Post Reply Bookmark Topic Watch Topic
  • New Topic

remove mthod  RSS feed

 
Devaki Nihar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Orion2.0 App Server
I am trying to call entity bean's remove method from session bean

Now the situation is like this
I get collection of Test1 remote interfaces by a finder method as like findById1
Now in the iteration i get the Test1 Data object by getXXX method of remote interface
I get one of the key from the data object
And depending upon that key i want to call finder method of Test2Home,It returns remote interface of Test2(and not a collection as the relation is 1-1)
And want to delete both that is Test1 and Test2 (in iteration).
My code is like -
try{
Test1Home test1Home = (Test1Home)initialContext.lookup("Test1");
Collection test1Coll = test1Home.findById1(id1);
Iterator test1CollItr = test1Coll.iterator();
Test2Home test2Home = (Test2Home) initialContext.lookup("Test2);
if(test1Coll.size() > 0){
while(test1CollItr.hasNext()){
Test1 test1 = (Test1)test1CollItr.next();
Test1Data test1Data = test1.getTest1Data();
float id2 = test1Data.getid2();
Test2 test2 = test2Home.findById2(id2);
test2.remove(); // here it gives remove exception
test1.remove()
}
}
} catch(FinderException f){
} catch(RemoveException r){
}
Here test2 get removed (record get deleted) but test1 remains in database
Is there is any concurrency problem?
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Test2 test2 = test2Home.findById2(id2);
test2.remove();
// here it gives remove exception
test1.remove()

Well, you have mentioned that you get an remove exception after you call the remove method on test2.

Does that mean that the subsequent remove() on test1 does not get executed ??

Do find out if the remove method gets executed, as i think that the remove exception might cause the execution to stop and go to catch block.. If this is the scenario, we might have to find out why the remove exception gets thrown.
[ August 23, 2005: Message edited by: Mohen Vijay ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!