Hi all,

I've come across some interesting CMP/CMR behaviour in JBoss 3.2.6.  

To explain, let me define a scenario.  Suppose we have two entities, 'Person' 
and 'PhoneNumber'.  We define a CMR relationship between them such that a 
'Person' can have relationships with multiple 'PhoneNumber' entities and each 
'PhoneNumber' can be associated with multiple 'Person' entities.


  | PhoneNumber
  | ID        Number
  | 1         07713
  | 2         87383
  | 
  | Person
  | Name    FullName
  | Bob     Robert
  | Mary    Mary
  | 
  | Person_PhoneNumber
  | PhoneNumber  Person
  | 1            Bob
  | 1            Mary
  | 2            Bob
  | 
If we now want to delete a particular PhoneNumber entity (eg. 1), we would 
locate it (using findByPrimaryKey or something) and then call it's 'remove' 
method.  What I'm finding is that the SQL that is generated is:


  | select ID, number from PhoneNumber where ID = 1; ##Find by PK
  | 
  | ## Generated as a result of the 'remove'
  | select Person from Person_PhoneNumber where PhoneNumber = 1;
  | 
  | select Name, FullName from Person where (Name=Bob) OR (Name=Mary);
  | 
  | delete from Person_PhoneNumber where (PhoneNumber=1) AND (Name=Bob OR 
Name=Mary);
  | 
  | delete from PhoneNumber where ID = 1;
  | 
  | 

Why are the related entities loaded (ie. why is anything from the 'Person' 
table loaded)?  Is there any way to stop this and hence speed up the process by 
avoiding the unnessary load?  

What I would expect is SQL along the lines of:


  | select ID, number from PhoneNumber where ID = 1; ## Find by PK
  | 
  | ## Generated as a result of the 'remove'
  | delete from Person_PhoneNumber where PhoneNumber = 1;
  | 
  | delete from PhoneNumber where ID = 1;
  | 
  | 

Any ideas or comments would be greatly appreciated :O)

Thanks in advance,

Jason


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3942459#3942459

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3942459


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to