Hi all, I have a many to one relationship between module and assessment (one module may have many assessments) in the project I am working on.
After creating some Modules, i do a getAssessments() and then add to the collection newly created Assessments. However when I want to tidy up after the test, I attempt to call .remove() on an assessment and the following error occurs : java.rmi.ServerException: Store failed; nested exception is: java.sql.SQLException: ERROR: ExecReplace: Fail to add null value in not null attribute module_code Strangely after calling assessment.remove() the container does an ejbStore... which seems strange to me. Could this problem be due to me using transactions wrongly? [14:56:21,347,Default] AssessmentBean : ejbCreate() [14:56:21,348,Default] TEST_ASS_1:Hello big world:http://www.aber.ac.uk/ass1:CS99910 [14:56:21,437,Default] AssessmentBean : ejbCreate() [14:56:21,437,Default] TEST_ASS_2:Hello big world advanced:http://www.aber.ac.uk/ass2:CS99920 [14:56:21,465,Default] AssessmentBean : ejbCreate() [14:56:21,466,Default] TEST_ASS_3:Hello big world easy level:http://www.aber.ac.uk/ass3:CS99930 [14:56:21,478,Default] DEBUG : BigTest : Assessments created ... [14:56:21,490,Default] DEBUG : BigTest : Assessments associated with module ... [14:56:21,497,Default] DEBUG : BigTest : test_Assessment() [14:56:21,503,Default] DEBUG : BigTest : tearDown() ... [14:56:21,521,Default] DEBUG : BigTest :1 Removed assList0 [14:56:21,524,Default] DEBUG : BigTest :1 Removed assList2 [14:56:21,528,Default] DEBUG : BigTest :2 Removed assList1 [14:56:21,538,Default] DEBUG : AssessmentBean : ejbStore() [14:56:21,553,Default] java.sql.SQLException: ERROR: ExecReplace: Fail to add null value in not null attribute module_code [14:56:21,553,Default] at org.postgresql.Connection.ExecSQL(Unknown Source) [14:56:21,554,Default] at org.postgresql.jdbc2.Statement.execute(Unknown Source) [14:56:21,554,Default] at org.postgresql.jdbc2.Statement.executeUpdate(Unknown Source) [14:56:21,555,Default] at org.postgresql.jdbc2.PreparedStatement.executeUpdate(Unknown Source) [14:56:21,555,Default] at org.jboss.resource.adapter.jdbc.local.PreparedStatementInPool.executeUpdate(PreparedStatementInPool.java:881) [14:56:21,556,Default] at org.jboss.ejb.plugins.cmp.jdbc.JDBCUpdateCommand.executeStatementAndHandleResult(JDBCUpdateCommand.java:46) [14:56:21,556,Default] at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:102) The code which creates the assessments is : Collection assessmentList1 = module1.getAssessments(); Collection assessmentList2 = module2.getAssessments(); Collection assessmentList3 = module3.getAssessments(); AssessmentLocalHome alh = this.getAssessmentLocalHome(); assList[0] = alh.create(assessmentId_1, moduleCode_1, assessmentDescription_1, assessmentUrl_1, assessmentDateDue_1, assessmentNumberOfMarkers_1); assList[1] = alh.create(assessmentId_2, moduleCode_2, assessmentDescription_2, assessmentUrl_2, assessmentDateDue_2, assessmentNumberOfMarkers_2); assList[2] = alh.create(assessmentId_3, moduleCode_3, assessmentDescription_3, assessmentUrl_3, assessmentDateDue_3, assessmentNumberOfMarkers_3); System.out.println("DEBUG : BigTest : Assessments created ..."); // module 1 has two assessments (1 and 3) // module 2 has one assessment (2) // module 3 has none assessmentList1.add(assList[0]); assessmentList2.add(assList[1]); assessmentList1.add(assList[2]); System.out.println("DEBUG : BigTest : Assessments associated with module ..."); assertTrue(module1.getAssessments().contains(assList[0])); assertTrue(module1.getAssessments().contains(assList[2])); assertTrue(module2.getAssessments().contains(assList[1])); The code which attempts to remove the assessment's is : Collection dud = module1.getAssessments(); for (int i=0; i<3; i++) { if(dud.contains(assList[i])) { dud.remove(assList[i]); System.out.println("DEBUG : BigTest :1 Removed assList"+i); } } Using Jboss 3.0.0 alpha, with container managed persistance and relationships. Thanks in advance for any help David. -- David Goodwin [ [EMAIL PROTECTED] ]----[ http://www.codepoets.co.uk ] [ BEng Software Engineering, Uni. of Wales, Aberystwyth ] _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user