[jboss-jira] [JBoss JIRA] Created: (HIBERNATE-68) assert collection.remove(this) is fail

Mike Khlu (JIRA) jira-events at lists.jboss.org
Tue Aug 14 08:58:01 EDT 2007


assert collection.remove(this) is fail
--------------------------------------

                 Key: HIBERNATE-68
                 URL: http://jira.jboss.com/jira/browse/HIBERNATE-68
             Project: Hibernate
          Issue Type: Task
            Reporter: Mike Khlu
         Assigned To: Steve Ebersole
            Priority: Minor


I've got simple ManyToMany case

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 

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?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list