Hi again,

as suggested in my previous post, I left the OCM annotations way to follow the XML mapping one but I always got a lot of errors. The wish is the same: have two POJOs, Type and Element so an element instance have a reference to it's type.

Errors are:
- org.xml.sax.SAXParseException: Document root element "jackrabbit-ocm", must match DOCTYPE root "null" - "Unknown mixin type ocm:discriminator for mapped class class com.imnet.oam.cm.Type; nested exception is javax.jcr.nodetype.NoSuchNodeTypeException: {http://jackrabbit.apache.org/ocm}discriminator";

Java classes are really simple, just two "beans":
public class Type {
   private String path;
   private String uuid;
   private String name;
   private String description;
   // Getters and setters follows...
}

public class Element {
   private String path;
   private String uuid;
   private String name;
   private String description;
   private Type type;
   // Getters and setters follows...
}

Here is my XML mapping file:
<?xml version="1.0" encoding="UTF-8"?>
<jackrabbit-ocm>
<class-descriptor className="Type" jcrType="my:type" jcrSuperTypes="nt:base" jcrMixinTypes="mix:referenceable">
   <field-descriptor fieldName="path" path="true"/>
   <field-descriptor fieldName="uuid" uuid="true"/>
<field-descriptor fieldName="name" jcrName="my:name" jcrMandatory="true"/>
   <field-descriptor fieldName="description" jcrName="my:description"/>
 </class-descriptor>
<class-descriptor className="Element" jcrType="my:element" jcrSuperTypes="nt:base" jcrMixinTypes="mix:versionable">
   <field-descriptor fieldName="path" path="true"/>
   <field-descriptor fieldName="uuid" uuid="true"/>
<field-descriptor fieldName="name" jcrName="my:name" jcrMandatory="true"/>
   <field-descriptor fieldName="description" jcrName="my:description"/>
   <bean-descriptor
     fieldName="type"
     jcrName="my:type"
     proxy="false"
     jcrType="my:type"
     jcrMandatory="true"
     jcrOnParentVersion="IGNORE"
converter="org.apache.jackrabbit.ocm.manager.beanconverter.impl.ReferenceBeanConverterImpl"
   />
 </class-descriptor>
</jackrabbit-ocm>

The application main methods registers all needed namespaces ("ocm", "my", etc...), instantiates a new ObjectContentManagerImpl (successfully) and tries to do something like this:
Type type = new Type()
type.setPath("/bar")
type.setName("Bar");
type.setDescription("A bar");
ocm.insert(type); <-- This throws a
ocm.save();

Element element = new Element()
element.setPath("/foo")
element.setName("Foobar");
element.setDescription("Foo bar");
element.setType((Type) ocm.getObject("/bar"));
ocm.insert(element);
ocm.save();

I really have no other ideas, I hope in yours... thank you!
--
GaS

Reply via email to