Hi there.

I have a strange problem with associating new records. I have a contentType which contains a list of content records. So I save a new content record like this:

----------------------------------------------------------------

ContentType contentType = dao.getContentTypeById(editForm.getCategory());

content.setContentType(contentType);
content.setContentTypeId(contentType.getId());
dao.saveContent(content);

------------------------------------------------------------------

This generates the following SQL

---------------------------------------------------------------------
1105083607870|20|0|statement|INSERT INTO content (title,summary,contentText,creationDate,eventStart,eventFinish,showBetweenDates,showFrom,showTo,orderOfContent,active,showOnMenu,showOnEventList,hits,link,contentTypeId) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |INSERT INTO content (title,summary,contentText,creationDate,eventStart,eventFinish,showBetweenDates,showFrom,showTo,orderOfContent,active,showOnMenu,showOnEventList,hits,link,contentTypeId) VALUES ('test2','test','test','Fri Jan 07 07:40:07 GMT 2005','Fri Jan 07 07:40:07 GMT 2005','Fri Jan 07 07:40:07 GMT 2005','false','Fri Jan 07 07:40:07 GMT 2005','Fri Jan 07 07:40:07 GMT 2005','0','true','true','false','0','false','4')
1105083607910|30|0|statement||SELECT LAST_INSERT_ID() FROM content LIMIT 1
1105083607910|0|0|commit||


---------------------------------------------------------------------

As you can see, the ContentTypeId has been correctly set and inserted into the record

Now having set the contentType reference in the content record before saving, I would have thought that the association would have been made.


-------------------------------------------------------------------

<class-descriptor
    class=" com.organisation.resources.schemas.database.Content"
    table="content">


<reference-descriptor name="contentType" class-ref="com.organisation.resources.schemas.database.ContentType" auto-retrieve="true" auto-update="true">

        <foreignkey field-ref="contentTypeId"/>

    </reference-descriptor>

</class-descriptor>

-------------------------------------------------------------------

But when I get a list of ContentTypes:


-------------------------------------------------------------------

<class-descriptor
    class="com.organisation.resources.schemas.database.ContentType"
    table="contentType">

    <collection-descriptor
        name="contents"

element-class-ref="com.organisation.resources.schemas.database.Content"
        auto-retrieve="true"
        auto-delete="true"
        auto-update="true"
        orderby="orderOfContent"
        sort="ASC">
        <inverse-foreignkey field-ref="contentTypeId"/>
    </collection-descriptor>

</class-descriptor>

----------------------------------------------------------------------

The new content record is not part of the list.

I'm thinking that I'm missing a step to make the association, but I'm not sure what it is. Can anyone help me out?




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to