There is a many to many relationship between students and subjects. At the end of the year this relationship has to be dissolved so new subjects can be assigned to each student the next year.
I thought it was going to be easy. First, get all the students in a list with a query. Then loop through this list while at the same time looping through each student | for(Student s : students){ | s.setYear(s.getYear() + 1); | q = manager.createQuery("select ss from Student s join s.subjects ss where s = :student"); | q.setParameter("student", s); | List<Subject> subjects = q.getResultList(); | if(subjects != null && subjects.size() > 0){ | System.out.println("The number of subjects for student " + | s.getNames() + " " + s.getSurname() + " is " + subjects.size()); | Iterator<Subject> iter = subjects.iterator(); | while(iter.hasNext()){ | Subject sj = iter.next(); //This is where it hits the fan | subjects.remove(sj); | } | } | I've also tried using a set (Set subjects = s.getSubjects()) with the same results. I also used a cast in the line with the problems. This is a short version of the exceptions: | javax.ejb.EJBException: null; CausedByException is: | null | at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46) | at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70) | at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134) | at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) | There is also a java.util.ConcurrentModificationException | at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449) | at java.util.AbstractList$Itr.next(AbstractList.java:420) | at au.com.databaseapplications.jtest.session.PrincipalSessionBean.newYear(PrincipalSessionBean.java:355) | The last line referred to in the exception above is the one indicated in the code. Any idea how one can do what seems to be simple? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953754#3953754 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953754 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