Bruce,
You are correct about the a.addB(b#) calls. I meant to remove this code
block and just send the unmarshalling code. I added the addB calls.
Since line 34 has setAutoStore(true), the b children are stored with the a,
and because A has a collection field mapping of Bs, the b children are
loaded with no errors/exceptions; no "depends" is needed.
However, this only works if I keep the "set-method" attribute from the
collection class mapping commented out. Put it in, and I get:
org.exolab.castor.jdo.DataObjectAccessException: no method to set value for
field: test.B in class: ClassMolder test.A
Just like before. I even tried executing just the load code in case there
was some issue with caching after create() but still got the same exception.
-doug
-----Original Message-----
From: Bruce Snyder
To: [EMAIL PROTECTED]
Sent: 6/3/2002 1:04 PM
Subject: Re: [castor-dev] JDO create() collection set-method not found
This one time, at band camp, Kvidera, Douglas said:
KD>Why does the Unmarshaller find the addB() method, but the Database
doesn't?
Doug,
Usually this type of exception is thrown because the setter cannot
be located. However, you've noted the setter in the mapping. Therefore
I'm apt to believe that this exception may be erroneous. What I
mean is that an exception should, in fact, be thrown, but Castor
may simply be throwing the wrong exception because of other issues.
In reviewing your example, I've found some flaws. The following is
a snippet of your code. I've added the necessary items and I've
also added the appropriate comments by each addition:
A a = new A();
a.setId(0);
B b0 = new B();
b0.setId(0);
b0.setCode("b0");
B b1 = new B();
b1.setId(1);
b1.setCode("b1");
B b2 = new B();
b2.setId(2);
b2.setCode("b2");
/* I added the following three calls to place the Bs into A's
collection
* for the Bs. Without these calls, A is not aware of the Bs at all.
*/
a.addB( b0 );
a.addB( b1 );
a.addB( b2 );
db.begin();
writer.println("Creating a and its children");
db.create(a);
/* Above you state that you're creating a and its children. Actually
only
* a is being created here because the mapping does not specify
anything
* about B depending on A. Without the depends keyword, composition
* does will take place.
*/
db.create( b0 );
db.create( b1 );
db.create( b2 );
db.commit();
db.begin();
writer.println("Loading a with children");
/* Again, above you state that you're loading a and its children.
Actually
* only a is loaded here because, again, there is no dependency
specified
* in the mapping. If you really want a and all the Bs, you'll need
to load
* each manually. With the call below, only a is loaded.
*/
a = (A) db.load(A.class, new Integer(a.getId()));
db.commit();
--
perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev