I have a problem trying to delete and then add new entities all in one call.

The situation is something like the following...

A 'Pupil' entity is associated with one or more 'subject' entities.  I have a 'Pupil' 
entity bean, 'Subject' entity bean and a linking 'PupilSubjectLink' entity bean. This 
last bean has two fields 'PupilID' and 'SubjectID', both set as keys. 

I have a CMR one-to-many relationship set up from the 'Pupil' entity to the 
'PupilSubjectLink' entity - called 'subjects'. 

When processing updates to the subject settings my code first deletes all subject 
links for the nominated pupil and then adds in the new subjects.

But the process fails as the first delete operation doesn't seem to work.

My delete code is something like the following....

       Pupil aPupil = PupilHome.findBy......
       Iterator anIterator = aPupil.getSubjects();
       while (anIterator.hasNext()) {
          PupilSubjectLink aLink = () anIterator.next();
          aLink.remove();
       } 
       aPupil.getSubjects().clear(); // is this necessary?
       
But this doesn't work. 

For example, if pupil 'A' starts in a situation where they are associated with 
subjects 'X' and 'Y', but then this is changed so that they are only associated with 
subject 'Y' then my app is blowing up on the final step when adding a link to subject  
'Y'. 

Any ideas?



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

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


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to