Sorry, I resubmit my mail which seems to have been cut half way through
while sending. I said: I have a problem which is driving me crazy... can
anyone help ?
Starting from a "movie.xsd" file I had Source Generator build some classes
for me, using the -type=j2 switch. I Compiled the sources ad obtained a
set of classes among which I have a "Movie" class which contains an array
of "Actors".
Feeding a movie.xml file contaning (also)...
------
<movie id="5"><title>My Movie</title>
<actor id="3"><name>Raoul Bova</name></actor>
<actor id="4"><name>Robert De Niro</name></actor>
</movie>
------
...I unmarshalled some wonderful objects which I was able to make
persistent via JDO to a JDBC database using a mapping.xml. Everything
following the examples, everything worked fine and pretty, the objects
could be marshalled/unmarshalled/stored to and from XML and the DB. Good.
Well, when I try to delete a "master" object though (the Movie) using
db.remove(movie), I suddenly get a java.lang.UnsupportedOperationException
generated at
org.exolab.castor.persist.ClassMolder$1$ArrayIterator.remove(ClassMolder.java:2959)
Here follows the code snippet:
----------
db.begin();
OQLQuery movieOQL = db.getOQLQuery( "SELECT p FROM movies.Movie p WHERE
p.id=$1" );
movieOQL.bind(5);
QueryResults results = movieOQL.execute();
if (results.hasMore()) {
Movie movie = (Movie) results.next();
db.remove(movie); // <--------- here the exception is thrown...
}
-----------
In the mapping file I declared the actor element as releted to movie
through a collection (it is actually a many-to-many relationship working
pretty well and populating correctly the M-M table):
<class name="movies.Movie" identity="id">
...
<field name="actor" type="movies.Actor" collection="array">
<sql name="id_actor" many-table="actor_movie" many-key="id_movie"/>
<bind-xml name="Actor" node="element"/>
</field>
</class>
I suspect that the problem arises from an incomplete implementation of the
Array-type collections in Castor. Infact I found that the class
ArrayIterator's method remove() always throws an
UnsupportedOperationException...
If this is the case how can I implement persistent objects containing
dependent objects? Should I use collection="collection" then ? I tried not
to use the -type=j2 switch in the generator but it didn't help.
Should I forget about source generator and build the classes manually ?
Thanks a lot in advance for any help.
Piero
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev