Title: creating a related object - id is null?
Sorry to repost - I'm really at a loss to explain this and can't find any answers. Thought maybe it was missed on the weekend.
I just tried the CVS version, but no luck - it gives a different errors about setEnabled not working, even though it is there and works in castor release (ie CVS is broken at the moment - its unrelated to my problem)
 
- Brett
 
-----Original Message-----
From: Brett Porter
Sent: Friday, 23 November 2001 9:50 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] creating a related object - id is null?

Hi,

My problem: calling create() on a TemplateAssoc gives the error "componentId must not be null" from the JDBC driver - so Castor is not setting the component properly. This is reasonably urgent - so if you are able to help please reply ASAP ;)

My situation: I have a class with a many-to-many assocation thith objects of itself. The association has a property. I use an assocation class to deal with this and model as follows:

PageTemplate { id : int, templateComponents : Collection (of TemplateAssoc) }
TemplateAssoc { id : int, pageId : int, component : PageTemplate, regionCode : int }

I want to get all TemplateAssoc and the components when I load the original PageTemplate. No circular references are possible as components have no sub-components.

Here are some parts of the mapping that are relevant. (Mapping is processed by XSLT, so any DTD fields are entered):
Assoc class:
        <field name="component" type="au.com.f2.shopping.page.PageTemplate" required="false" direct="false" lazy="false">

            <sql name="componentId" dirty="check"/>
        </field>
        <field name="pageId" type="integer" required="false" direct="false" lazy="false">
            <sql name="pageId" type="integer" dirty="check"/>
        </field>
PageTemplate:
        <field name="templateComponents" type="au.com.f2.shopping.product.TemplateComponentAssociation" collection="arraylist" lazy="true">

            <sql many-key="pageId"/>
        </field>

I have checked that the component is correct and has its id set. The castor.log file has:

SQL for creating au.com.f2.shopping.page.PageTemplate: INSERT INTO page_templates(name,inputUrl,outputFilename,publishFlag,component,lastmodified) VALUES (?,?,?,?,?,?)

SQL for loading au.com.f2.shopping.page.PageTemplate:  SELECT page_templates.name,page_templates.inputUrl,page_templates.outputFilename,page_templates.publishFlag,page_templates.component,page_templates.lastmodified,template_component_assocs.id FROM page_templates LEFT OUTER JOIN template_component_assocs ON page_templates.id=template_component_assocs.pageId WHERE page_templates.id=?

SQL for creating au.com.f2.shopping.page.TemplateComponentAssociation: INSERT INTO template_component_assocs (componentId,pageId,regionCode,lastmodified) VALUES (?,?,?,?)

SQL for loading au.com.f2.shopping.page.TemplateComponentAssociation:  SELECT template_component_assocs.componentId,template_component_assocs.pageId,template_component_assocs.regionCode,template_component_assocs.lastmodified FROM template_component_assocs WHERE template_component_assocs.id=?

...

Castor: Loading au.com.f2.shopping.page.PageTemplate (4)
Castor: Creating au.com.f2.shopping.page.TemplateComponentAssociation (null)

Can anyone help? This is Castor 0.9.3 (not CVS - this is going into production and I'm not comfortable using anything that changes too frequently now :)

Thanks in advance!

Cheers,
Brett

~*~*~*~*~*~*~
Brett Porter - Web Developer
f2 Network ~ everything essential
Ph: +61 2 8596 4437
Email: [EMAIL PROTECTED]

Reply via email to