You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Grant McGovern <gr...@gmail.com> on 2019/08/14 02:11:17 UTC

Are nested array node types valid in Jackrabbit JCR?

Hello,

Copying some bits from the corresponding Stackoverflow post I posted here: https://stackoverflow.com/questions/57487251/are-nested-array-node-types-valid-in-jackrabbit-jcr <https://stackoverflow.com/questions/57487251/are-nested-array-node-types-valid-in-jackrabbit-jcr>.

Basically, I’m attempting to translate the following data model (business requirement) into a JCR structure, and add it to an existing parent structure.

{
    "someProperty": [
        [ "some-property-1", "some-property-2" ],
        [ "some-property-3", "some-property-4" ]
    ]
}
I’m new to the JCR world, but I’ve run into some issues with implementing this ask. It seems like there’s no way to add a Node object that isn’t named, which is what the nested subarrays would be in this case.

There’s some more details on the SO link I posted above, but briefly speaking, is it possible to store nested arrays in a JCR structure?

Thanks,
Grant

Re: Are nested array node types valid in Jackrabbit JCR?

Posted by Woonsan Ko <wo...@apache.org>.
On Tue, Aug 13, 2019 at 9:11 PM Grant McGovern
<gr...@gmail.com> wrote:
>
> Hello,
>
> Copying some bits from the corresponding Stackoverflow post I posted here: https://stackoverflow.com/questions/57487251/are-nested-array-node-types-valid-in-jackrabbit-jcr <https://stackoverflow.com/questions/57487251/are-nested-array-node-types-valid-in-jackrabbit-jcr>.
>
> Basically, I’m attempting to translate the following data model (business requirement) into a JCR structure, and add it to an existing parent structure.
>
> {
>     "someProperty": [
>         [ "some-property-1", "some-property-2" ],
>         [ "some-property-3", "some-property-4" ]
>     ]
> }
> I’m new to the JCR world, but I’ve run into some issues with implementing this ask. It seems like there’s no way to add a Node object that isn’t named, which is what the nested subarrays would be in this case.
>
> There’s some more details on the SO link I posted above, but briefly speaking, is it possible to store nested arrays in a JCR structure?

In my understanding, JCR 2.0 specification is not supposed to allow to
add an unnamed node. [1]
So, possible options in JCR structure probably include the following:
1. Each array in a multi-value property in a child node with either
same name siblings (e.g, "propnode", "propnode", ...) in Jackrabbit v2
or generated named (e.g, "propnode_1", "propnode_2", ...) nodes in
Oak.
2. Generated named properties without child nodes. e.g, @prop1 = [
"value1", "value2", ...], @prop2 = [ "value3", "value4", ...].
3. Single string property with specific formatted string such as json
format. @propinjson = "[ ... ]"

#1 looks more organized, but less convenient and less performant if
you want to search it - through JCR Query - by the nested node's
values.
#2 looks less organized, but probably more efficient in query.
#3 is problematic in queries with equals or like constraints.

Anyway, it will depend on your use case. Mostly on how you want to
query those, I guess.

Regards,

Woonsan

[1] https://docs.adobe.com/docs/en/spec/javax.jcr/javadocs/jcr-2.0/javax/jcr/Node.html#addNode(java.lang.String)

>
> Thanks,
> Grant