jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Kruse <r...@kruseonline.net>
Subject Re: OCM Collection Question
Date Mon, 20 Apr 2009 04:45:18 GMT
I think I figured it out.  I had tried setting the path of the child object
directly but it wasn't working.  The reason was because the wrapper I was
using for the save was checking if the path existed and only did an insert
if it didn't exist.  In a SNS this doesn't work because even though the path
existed I still want to do an insert.


On Fri, Apr 17, 2009 at 5:41 PM, Ryan Kruse <ryan@kruseonline.net> wrote:

> Hello,
>
> I am VERY new to Jackrabbit (today) and am trying to get my collection to
> save how I want, but not having any luck.  Any help would be greatly
> appreciated.
>
> I have a "CommentList" object that has a java.util.List of "AuthoredText"
> objects.  AuthoredText has a creationDate field.  Each time a user adds a
> new AuthoredText object to a CommentList, I save the entire CommentList
> using ocm.update or ocm.insert if the CommentList is new.  Doing the
> ocm.update appears to resave all of AuthoredText objects previously saved in
> the CommentList instead of just the newly created one, resetting the
> creationDates on all of them.  Is there any way I can save the new
> AuthoredText directly or at least have the others not updated when I save
> the master CommentList object?
>
> Here are some relavant pieces of info....
>
> *Some mapping info....*
>    <class-descriptor
> className="com.hyper9.service.workspace.ocm.CommentList"
> jcrType="h9:commentList"
>         extend="com.hyper9.service.resource.ocm.HierarchyNode"  >
>         <collection-descriptor fieldName="comments" proxy="true"
> jcrType="h9:authoredText" jcrElementName="h9:comment"
>             elementClassName="com.hyper9.service.resource.ocm.AuthoredText"
> jcrSameNameSiblings="true"
>
> collectionConverter="org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl"
> />
>     </class-descriptor>
>
>     <class-descriptor
> className="com.hyper9.service.resource.ocm.AuthoredText"
> jcrType="h9:authoredText"
>         extend="com.hyper9.service.resource.ocm.AbstractResourceObject">
>         <field-descriptor fieldName="author" jcrName="h9:author" />
>         <field-descriptor fieldName="text" jcrName="h9:text" />
>     </class-descriptor>
>
>     <class-descriptor
> className="com.hyper9.service.resource.ocm.AbstractResourceObject"
>         abstract="true">
>         <field-descriptor fieldName="path" path="true" />
>         <field-descriptor fieldName="creationDate" jcrType="Date"
> jcrName="jcr:created" jcrProtected="true"
>             jcrAutoCreated="true" />
>     </class-descriptor>
>
>
> *Some NodeType info...*
>     <nodeType name="h9:commentList">
>         <supertypes>
>             <supertype>h9:hierarchyNode</supertype>
>         </supertypes>
>         <childNodeDefinition name="h9:comment" autoCreated="false"
> defaultPrimaryType="h9:authoredText"
>             mandatory="false" onParentVersion="COPY" protected="false"
> sameNameSiblings="true">
>             <requiredPrimaryTypes>
>                 <requiredPrimaryType>h9:authoredText</requiredPrimaryType>
>             </requiredPrimaryTypes>
>         </childNodeDefinition>
>     </nodeType>
>
>     <nodeType name="h9:authoredText">
>         <supertypes>
>             <supertype>nt:hierarchyNode</supertype>
>         </supertypes>
>         <propertyDefinition name="h9:text" requiredType="String"
> autoCreated="false" mandatory="true"
>             onParentVersion="COPY" protected="false" multiple="false" />
>         <propertyDefinition name="h9:author" requiredType="String"
> autoCreated="false" mandatory="true"
>             onParentVersion="COPY" protected="false" multiple="false" />
>     </nodeType>
>
> Thanks!
> Ryan
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message