You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sverker Abrahamsson <sv...@abrahamsson.com> on 2010/11/14 00:45:22 UTC
Collection mapping with OCM
Hi,
I can't figure out how to configure a collection mapping with OCM. The
definition of my node type looks like this:
[lt:file] > nt:hierarchyNode, mix:referenceable
orderable
+ lt:content (nt:base)
= lt:resource
mandatory multiple COPY
+ lt:sample (nt:base)
= lt:resource
multiple COPY
and some more child nodes and properties.
The first attempt was just a simple mapping like this:
@Collection(jcrName="lt:content", jcrOnParentVersion="COPY")
private List<Base> content;
That gives this exception:
00:34:08,913 ERROR [AbstractTestBase] Cannot create new node of type
lt:resource from mapped class class
com.limetransit.jcr.model.DefaultResourceImpl; nested exception is
javax.jcr.nodetype.ConstraintViolationException: No child node definition
for collection-element found in node /test/testfile/lt:content
org.apache.jackrabbit.ocm.exception.ObjectContentManagerException: Cannot
create new node of type lt:resource from mapped class class
com.limetransit.jcr.model.DefaultResourceImpl; nested exception is
javax.jcr.nodetype.ConstraintViolationException: No child node definition
for collection-element found in node /test/testfile/lt:content
javax.jcr.nodetype.ConstraintViolationException: No child node definition
for collection-element found in node /test/testfile/lt:content
This variant is actually working:
@Collection(jcrName="lt:content", jcrElementName="lt:content",
jcrOnParentVersion="COPY", elementClassName=Base.class,
collectionConverter=NTCollectionConverterImpl.class)
private List<Base> content;
but the issue with NTCollectionConverterImpl is that I have my sample node
also, which has the same node type and then this converter can't keep them
apart. Also, how does this look in the repository?
What would be the correct way to map these nodes?
Best regards
Sverker