|
I gave the hashmaps some more thought. I think the reason JCR (and thus PHPCR) do not have hashmaps is because an unstructured node basically /is/ a hashmap. It has fields with string names and values of various types.
I think for the ODM, the best approach would be to have a @Hashmap mapping that is a special case of @Child. The value is an array that is mapped to a child node with the name of the field. This even allows to map nested arrays, fields that contain an array are just added as child node with that name. (the only thing i see here: we lose the order as children and properties are handled different).
When loading, the child node (and nested children) are mapped to array, or the propertycollection thing we use for multivalue, if that can handle keys.
i think this would be the most flexible approach and should not even be very difficult. when you store large nested arrays here, it becomes a bit slow but i think that would be a design flaw to use deep nested arrays as odm fields anyways.
the other options i see is adding the array_keys/values split workaround into the odm directly, but that only handles flat arrays and converts all values to string whereas the child node would keep DateTime, int, float, boolean and stream types as well. or we could serialize the array into a string property. but that feels yuk.
|