You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Grégory Joseph <gr...@magnolia-cms.com> on 2013/06/14 17:40:26 UTC

Jackrabbit creates a Reference typed property, despite the nt requesting a WeakReference ? Bug or feature ?

Hi there,

We have the following in a nodetype definition:
    <propertyDefinition name="foobar" requiredType="WeakReference" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false" isFullTextSearchable="false" isQueryOrderable="false"/>


.. and the following code …
            nodeA.setProperty("foobar", nodeB);

The Javadoc of javax.jcr.Node#setProperty(String name, Node value) says:
[…]
     * If the named property does not yet exist and the repository cannot
     * determine whether a <code>REFERENCE</code> or <code>WEAKREFERENCE</code>
     * property is intended, then a <code>REFERENCE</code> property is created.
[…]

… so we assumed that the NT def would drive this decision.

But when exporting nodeA, we see that the property was created as a (hard) Reference. Looking at the code of org.apache.jackrabbit.commons.AbstractNode#setProperty(String name, Node value), it looks like it's not trying at all to make any sort of informed decision, and just delegates to javax.jcr.ValueFactory#createValue(Node value) which is explicitly spec'd to create (hard) Reference properties.

Is this supposed to be this way ? Is this an implementation bug, a documentation bug, or just something that I'm overseeing (which is far from unlikely) ?

Thanks for any hint !

Cheers,

-greg