You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Aleksei Lukin <lu...@stu.cn.ua> on 2008/08/28 10:50:34 UTC

OCM: how to persist Maps?

Hello, All!

I did not found example in "testmodel" to work with simple maps like  HashMap<String,String>.

May be we need @Map annotation?

-- 
SY, Alex Lukin
RIPE NIC HDL: LEXA1-RIPE

Re: OCM: how to persist Maps?

Posted by Christophe Lombart <ch...@gmail.com>.
Hi Alex,

Yes, the Map support was not very good and I worked on that this week.
With my latest commit, you can use a map like this :

@Node
public class MyClass
{

    @Collection Map<String,AnotherClass> map;

}

Of course, HashMap is also supported. AnotherClass has to be a persistent
class. Is it your case ?
The current limitation is to use a String as the map Key because the key is
used to create a subnode matching to the element stored into the map.  I'm
thinking about how to support other types for the map key.

See the unit test :
/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest
to get an example.




> May be we need @Map annotation?


Why not to use the Jpa annotation names ? OneToMany, ManyToOne, ...
That the same for @Node. We can rename it into @Entity

Let me know if you need more help or if you have some questions.


br,
Christophe