jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Giguère" <vincent.gigu...@gmail.com>
Subject OCM : Mapping a java.util.Map of referenced beans
Date Mon, 09 Jun 2008 00:59:25 GMT

Is there a possibility to map a java.util.Map property containing REFERENCED
content (Map<String, SomeBeanStoredAsReferences>)
I am attempting to do so and I keep on running on problems.

I am working with the trunk of jackrabbit-ocm since I have seen support for
maps (ManageableMap & ManageableMapImpl). However, I do not find the
of the BeanReferenceCollectionConverterImpl for maps

In the example below: the map property is annotated with

The BeanReferenceCollectionConverterImpl fails at restoring the Map content
because the ManageableObject associated to the Map property is not an
instance of ManageableCollection (it is in fact a ManageableMap).

My test is quite simple:


@Node(jcrMixinTypes = "mix:versionable")
public class Parent extends AbstractReferenceableEntity {

    @Field(uuid = true, id = true)
    private String id;

    @Field(path = true)
    private String path = defaultPath();

    @Collection(collectionConverter =
    private Map<String, Child> childRefs = new HashMap<String, Child>();

getters and setters...


@Node(jcrMixinTypes = "mix:versionable")
public class Child extends AbstractReferenceableEntity {

    private String path = defaultPath();

    @Field(uuid = true)
    private String id;

getters and setters...



    public void persisting_and_restoring_child_references_in_map() {

        Parent parent = new Parent();

        parent.getChildRefs().put("c1", (Child)this.childDao.persist(new
        parent.getChildRefs().put("c2", (Child)this.childDao.persist(new
        parent.getChildRefs().put("c3", (Child)this.childDao.persist(new


        Parent reloaded  = (Parent) this.parentDao.loadById(parent.getId());

        assertThat(reloaded.getId(), is(notNullValue()));

        assertThat(reloaded.getChildRefs(), is(notNullValue()));
        assertThat(reloaded.getChildRefs().size(), is(equalTo(3)));

        assertThat(reloaded.getChildRefs().get("c1"), is(notNullValue()));
        assertThat(reloaded.getChildRefs().get("c2"), is(notNullValue()));
        assertThat(reloaded.getChildRefs().get("c3"), is(notNullValue()));


I would really appreciate your help.

Also, if you know of a working alternative that would make my unit test
pass, I would be grateful.

Thanks in advance :)
Vincent Giguère

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message