jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christophe Lombart" <christophe.lomb...@gmail.com>
Subject Re: mix:referenceable with OCM
Date Fri, 05 Oct 2007 07:27:12 GMT
On 10/5/07, Kaizer <Kaizers@mastek.com> wrote:
> Thanks a lot! I had a look at the test cases and that helped! But i had a
> few
> general queries..
> 1. What are the advantages of using referencing here? One can still
> persist
> "anotherContent" by specifying its attributes in the mapping.xml, so when
> should i consider using referencing?

If you specify "anotherContent" as a bean-descriptor in the main object (in
our case "MyContent"),  by default, that means it is a subnode of
"MyContent". there are some situation where you want to point to another
node (which is not a subnode).

Maybe a good exemple is : one article has a list of related articles. here
is the repo structure(with very bad name).

     UUID : 123455
     text: "....."
     UUID  : 6987787
     text: "....."
     UUID : 9966565
     text: "....."
     RelatedArticles : 123455, 6987787
     UUID : 66655656
     text: "....."
     UUID : 12890
     text: "....."
     RelatedArticles : 66655656

In this case, when I update my article, this is not necessary to update the
related article contents. I can only modify the list of the related
articles. In such case, you can use multi value property based on the
REFERENCE type (RelatedArticles). The OCM converter
"RefenceCollectionConverterImpl" is doing this for you.

But there are some alternatives to referencable nodes  :-) (see
We should provide some converters to support this kind of proposal. I Think
is should be possible to build a variant of ReferenceCollectionConverterImpl
(and ReferenceBeanConverterImpl)  that provide the flexibility defined in
the David's Rule 5.

2. As per the documentation of ReferenceBeanConverterImpl, modifications on
> the referenced bean attributes are ignored. Does this mean that after
> persisting, if "anotherContent" is modified, the reference in "myContent"
> will not reflect the changes?

No with the following code, that's ok :

AnotherContent anotherContent = new AnotherContent();
MyContent myContent = new MyContent();
ocm.save();  // another content will not be a subnode of mycontent. Only its
uuid is stored as REFERENCE prop inside myContent

MyContent myContent = ocm.getObject("/myContent);
anotherContent  = myContent.getAnotherContent();
String prop = anotherContent.getMyProp(); // if proxy = true, the retrieve
of anotherContent is made at that time.

myContent.getAnotherContent()..setMyProp("pop1"); // This update will be
ignored by the ocm

AnotherContent   = ocm.getObject("/anotherContent);

Let me know if it is not clear (sorry it is friday :-) )


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