Hello,
I have found a situation where Castor can't handle updates on a
reasonably complex object model. I have 3 classes Projects, Employees
and Roles and 2 association classes that exist in relationships with
each other of varying cardinalities (see comedy ASCII UML below). The
real world problem I am trying to model is that Employees can be
assigned to one Project many times in different Roles, with different
day rates... hence using association classes rather than just using a
many-table to relate them with castor.
The first time you assign an employee to a project in a role it works
fine, but if you try and assign the employee again with a different role
it fails because as Castor walks the tree of dependencies it comes
across the same objects more than once and gives
[ERROR,Default] org.exolab.castor.jdo.DuplicateIdentityException: update
object which is already in the transaction
I'm sure it's not a mapping issue as it works correctly the first time.
Could I get around this by using a different transaction level? Should I
turn autostore off in JBoss?
Does any know of a work-around to this problem?
Because there are a lot of classes and mappings involved I haven't
provided much detail, I'm just hoping someone else might recognise the
limitation and has a work-around.
-------- ------------- ---------
| | | | | |
|Employee|1 *|EmployeeRole |* 1| Role |
| |-----| |------| |
| | | | | |
-------- ------------- ---------
1|
|
*|
-------------------- ----------
| | | |
|EmployeeRoleProject |1 1| Project |
| |-------| |
| | | |
-------------------- ----------
It all happens inside Castor/Jboss with autostore set to true... I
assemble all the objects, set up the relationships (bi-directionally of
course) and then call
update on one of them... Castor walks through the related objects
updating each in turn... and bursts if the same object appears twice.
i.e.
EmployeeRole e = employeeEJB.findEmployeeRole(e_id);
Project p = projectEJB.findProject(p_id);
//create a new employee role project association class
EmployeeRoleProject n = new EmployeeRoleProject();
//set up the relationships with the existing objects
n.setEmployeeRole(e);
e.addEmployeeRoleProject(p);
n.setProject(p);
p.setEmployeeProjectRole(n);
//set other parameters of the employeeRoleProject
e.setRate(500);
e.setOtherVariables(xxxx);
//crunch time... try to save the whole thing by calling
p = projectEJB.updateProject(p); //<-- breaks
Patrick
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev