-->
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.  [ 3 posts ] 
Author Message
 Post subject: assert collection.remove(this) is fail
PostPosted: Fri Aug 10, 2007 4:45 am 
Beginner
Beginner

Joined: Sat Jan 14, 2006 10:05 am
Posts: 22
Location: spb.ru
Hello, community

What do you think about assertion in subject?

so, look at this

Code:
class A {
  @ManyToMany
  Set<B> bes=...;
}

class B {
  @ManyToMany(mappedBy="bes")
  Collection<A> aes=...;

  void addAssociation(A newbie){
   // everything is clear. and works well
   ....
  }
  void removeAssociation(A associated){
     assert aes.remove(associated); // works fine
     assert a.bes.remove(this);   // doesn't works !!!
  }
}

if you try to run simple "exploit", you would be unhappy
Code:
void foo(){
  A a = .... // gets poxy from session
  B b = a.iterator().next(); // gets proxy of associated entity by association

  b.removeAssociation(a); // we'll got a fail
}

Of course, I know the cause:
1. method call would be delegated to entity (target) by proxy
2. so, "this" in method body means entity (target) not a proxy
3. We can't find entity in collection of proxies, in spite of we have proxy with such ID there

What do you think about this issue?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 3:14 am 
Beginner
Beginner

Joined: Sat Jan 14, 2006 10:05 am
Posts: 22
Location: spb.ru
I don't believe, that you arn't intrested in


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 1:09 pm 
Beginner
Beginner

Joined: Sat Jan 14, 2006 10:05 am
Posts: 22
Location: spb.ru
Shall I raise the issue in JIRA?


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

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.