[OJB-developers] M-N Unidirectional updates (notably removal of dependent objects) Failing
Brought to you by:
thma
From: Galvin H. <gk...@ya...> - 2002-06-13 19:30:03
|
Btw, CVS build is failing since the javac compiler is getting confused about IdentityHashMap() in PersistentBrokerImpl - it exists in java.util and also in ojb.broker.util. Took out the newest CVS version and compiled it - wrote a junit test case to handle updates to a M-N unidirectional relationship: This test case does the following: 1) Retrieves a person 2) Gets its associated projects 3) Adds a project to a particular person (this passes) 4) Checks to see if the person is associated to the new project 5) Removes all projects to a particular person (this fails) 6) Checks to see if the person has no associated projects This really limits the use of the current CVS unidirectional M-N mapping. public void testUpdateUnidirectional() { try { PersonUnidirectional p = new PersonUnidirectional(); p.setId(1); Query q = QueryFactory.newQuery(p); p = (PersonUnidirectional) broker.getObjectByQuery(q); Collection projects = p.getProjects(); ProjectUnidirectional[] projectArray = (ProjectUnidirectional[]) projects.toArray(new ProjectUnidirectional[0]); // load it assertNotNull(projects); int count = projects.size(); ProjectUnidirectional proj = new ProjectUnidirectional(); proj.setTitle("MARS"); proj.setDescription("colonization of planet Mars"); p.getProjects().add(proj); broker.beginTransaction(); broker.store(p); broker.commitTransaction(); broker.clearCache(); p = (PersonUnidirectional) broker.getObjectByQuery(q); assertEquals(count + 1, p.getProjects().size()); broker.beginTransaction(); projects = p.getProjects(); projects.clear(); p.setProjects(projects); broker.store(p); broker.commitTransaction(); broker.clearCache(); p = (PersonUnidirectional) broker.getObjectByQuery(q); assertEquals(0, p.getProjects().size()); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(); fail(t.getMessage()); } } __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com |