Hi All,
I have defined two classes called "Timesheet" and "Activity". A
Timesheet object contains a collection of Activity objects. Activity
objects are 'dependent' on Timesheet objects with each Activity having
an associated 'timesheetId' field). This means that whenever I want to
delete a Timesheet object (from the "timesheet" db table) I also want to
automatically delete all Activity objects (in the "activity" db table)
with that timesheetId.
My "mapping.xml" is set up as follows :-
<mapping>
<!-- Mapping for Activity -->
<class name="cookietime.beans.Activity" identity="activityId"
key-generator="IDENTITY" >
<description>Activity definition</description>
<map-to table="activity" xml="activity" />
<field name="activityId" type="integer">
<sql name="activityId" type="integer" />
<xml name="activityId" node="attribute"/>
</field>
<field name="timesheetId" type="integer">
<sql name="timesheetId" type="integer" />
<xml name="timesheetId" node="attribute"/>
</field>
+ other fields
</class>
<!-- Mapping for Timesheet -->
<class name="cookietime.beans.Timesheet" identity="timesheetId"
key-generator="IDENTITY">
<description>Timesheet definition</description>
<map-to table="timesheet" xml="timesheet" />
<field name="timesheetId" type="integer">
<sql name="timesheetId" type="integer" />
<xml name="timesheetId" node="attribute"/>
</field>
<field name="activities" type="cookietime.beans.Activity"
collection="collection">
<sql many-key="timesheetId" />
<xml name="activity" node="element" />
</field>
+ other fileds
</class>
</mapping>
How do I adjust my mapping file so that this deletion automatically
happens ? I read in the docs that I should use the "depends" attribute
of the "class" element, i.e. have :-
<class name="cookietime.beans.Activity" identity="activityId"
key-generator="IDENTITY" depends="cookietime.beans.Timesheet">
When I try this I get the following error: -
org.exolab.castor.mapping.MappingException: Depends not found
org.exolab.castor.mapping.xml.ClassMapping@75078b
cookietime.beans.Activity at
org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(MappingLoader.java:326)
at
org.exolab.castor.jdo.engine.JDOMappingLoader.createDescriptor(JDOMappingLoader.java:147)
at
org.exolab.castor.mapping.loader.MappingLoader.loadMapping(MappingLoader.java:211)
at
org.exolab.castor.jdo.engine.JDOMappingLoader.loadMapping(JDOMappingLoader.java:294)
at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:278) at
org.exolab.castor.jdo.engine.DatabaseRegistry.loadDatabase(DatabaseRegistry.java:289)
at org.exolab.castor.jdo.JDO.getDatabase(JDO.java:538) at
cookietime.servlets.InitServlet.service(InitServlet.java:63) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:484)
Can anyone tell me how to get this working on Castor 0.93 ?
Cheers,
Graeme
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev