Hi, Marc.
Thank you for the hint. In fact I found this in my castorbuilder.properties
(uncommented by default):
# Set to true if you want the generated source code to contain
# Extra methods for the collection fields, such as get/set using
# the collection type in addition to the type-safe array.
# Set this to true if you want your code to be more compatible
# with Castor JDO. This is false by default.
#
org.exolab.castor.builder.extraCollectionMethods=true
With this option activated, I get additional methods generated:
public poc.castor.prodobj.CatalogStructure getCatalogStructure(int
index)
public poc.castor.prodobj.CatalogStructure[] getCatalogStructure()
public java.util.ArrayList getCatalogStructureAsReference()
public void setCatalogStructure(int index,
poc.castor.prodobj.CatalogStructure vCatalogStructure)
public void setCatalogStructure(poc.castor.prodobj.CatalogStructure[]
catalogStructureArray)
public void setCatalogStructure(java.util.ArrayList
catalogStructureCollection)
public void setCatalogStructureAsReference(java.util.ArrayList
catalogStructureCollection)
Now in my mapping I define this property as
<class name="poc.castor.prodobj.Product" identity="articleNo">
...
<field name="catalogStructures.catalogStructureAsReference"
type="poc.castor.prodobj.CatalogStructure" required="true"
collection="arraylist">
<sql many-key="productId"/>
</field>
</class>
<class name="poc.castor.prodobj.CatalogStructure" identity="id"
dependent="true">
...
</class>
This is sufficient to make the application start. However, upon create and
commit of a Product object, only the product data gets stored and Castor
does not care for the dependt object(s) at all. I even removed the required
database tables for them, and Castor does not complain.
Why does Castor not care for the CatalogStructure objects in my collection?
Hiran Chaudhuri
> -----Original Message-----
> From: Marc Lehnert [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 25, 2003 11:07 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] FW: Problem with mapping generated files
>
>
> Hi,
> I also got the same problem and solved it by editing a
> castorbuilder.properties file containing the following line:
>
> org.exolab.castor.builder.collections.reference.suffix=ArrayList
>
> Furthermore I edited the field-tag and added Attributes for the now
> additionaly generated getter- and setter-methods:
>
> <field ... get-method="getCatalogStructureArrayList"
> set-method="setCatalogStructureArrayList">...</field>
>
> This worked for me. In my opinion this is a bug in the
> SourceGenerator or JDO, I don't know. It is not only the
> initialization which does not work
> without these methods but also a database rollback fails (for me) if I
> don't add them.
>
> Greets,
> Marc.
>
> CH> Hi there.
>
> CH> Having generated some classes from a schema (works very
> smooth) I now try to
> CH> persist them with Castor JDO. My thought is to simply
> create the tables and
> CH> a mapping file accordingly. However I'm facing problems I
> feel unable to
> CH> solve, though I believe it's just lack of experience.
>
> CH> The classes I got generated follow the bean pattern, and
> there are such
> CH> pattern for simple properties as well as indexed
> properties. Now when I try
> CH> to map such a indexed property (namely the
> CH> CatalogStructures/CatalogStructure property) I keep
> getting such exceptions:
>
> CH> org.exolab.castor.mapping.MappingException: The return
> type for method
> CH> public poc.castor.prodobj.CatalogStructure[]
> CH> poc.castor.prodobj.CatalogStructures.getCatalogStructure)
> does not match the
> CH> declared field type [Ljava.lang.Object;
> CH> at
> CH>
> org.exolab.castor.persist.FieldMolder.findAccessor(FieldMolder
> .java:785)
> CH> at
> CH> org.exolab.castor.persist.FieldMolder.<init>(FieldMolder.java:567)
> CH> at
> CH> org.exolab.castor.persist.ClassMolder.<init>(ClassMolder.java:367)
> CH> at
> CH>
> org.exolab.castor.persist.ClassMolder.resolve(ClassMolder.java:519)
> CH> at
> org.exolab.castor.persist.LockEngine.<init>(LockEngine.java:168)
> CH> at
> CH>
> org.exolab.castor.persist.PersistenceEngineFactory.createEngin
> e(PersistenceE
> CH> ngineFactory.java:83)
> CH> at
> CH>
> org.exolab.castor.jdo.engine.DatabaseRegistry.<init>(DatabaseR
> egistry.java:2
> CH> 04)
> CH> at
> CH>
> org.exolab.castor.jdo.engine.DatabaseRegistry.<init>(DatabaseR
> egistry.java:1
> CH> 63)
> CH> at
> CH>
> org.exolab.castor.jdo.engine.DatabaseRegistry.loadDatabase(Dat
> abaseRegistry.
> CH> java:289)
> CH> at org.exolab.castor.jdo.JDO.getDatabase(JDO.java:583)
> CH> at poc.castor.Test.main(Test.java:57)
>
> CH> I found out that Castor gets the correct method public
> CH> poc.castor.prodobj.CatalogStructure[]
> CH>
> poc.castor.prodobj.CatalogStructures.getCatalogStructure(),
> but claims this
> CH> one to be the wrong. From the source in FieldMolder I
> understand that a
> CH> method returning java.lang.Object[] is required.
>
> CH> Do I understand correctly? Why are other types of arrays
> not accepted? And
> CH> what's the recommended way to go if you get these classes
> generated (I don't
> CH> want to edit them much since regeneration is likely).
>
> CH> Thanks for your help, files are attached.
>
> CH> Hiran
>
> CH> -----------------------------------------
> CH> Hiran Chaudhuri
> CH> SAG Systemhaus GmbH
> CH> Elsenheimerstra�e 11
> CH> 80687 M�nchen
> CH> Germany
> CH> [EMAIL PROTECTED]
> CH> Phone +49-89-54742-134
> CH> Fax +49-6151-9234-5134
>
> -----------------------------------------------------------
> 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