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: OCM, queries and version history
Date Fri, 16 Jan 2009 09:47:26 GMT
Hi,

Searching objects in the version history is not yet supported. For the
moment, you can only get the version history and loop on the different
versions (see the unit test AnnotationBasicVersionningTest).

There is a workaround but this is not the ideal solution :
Make your own jcr query to get versions (as explained in the jcr
specification - see 8.2.2.2) and get the object with the ocm method
getObject(String path, String versionName)

Hope this help

Christophe

On Wed, Jan 14, 2009 at 17:43, Gaetano Sferra <gsferra@imnet.it> wrote:

> Hi again,
>
> it's possible to search an object by the value of an attribute thought the
> version history?
> Ok, let me to better explain it; I have an object like this (correctly
> mapped in a xml descriptor and defined (CND) - it has the "mix:versionable"
> type too):
>
> public class MyObject {
>   private String path;
>   private String foo;
>   // other attributes, getters and setters follows ...
> }
>
> I wish to check in many versions of this object differing for the value of
> "foo" attribute (ie: "bar", "dummy", "lazy", etc...) and then I hope to
> retrieve one of them searching for it's "foo" value.
> Example:
>
> MyObject myobject = new MyObject();
> myobject.setPath("/itsme");
> myobject.setFoo("bar");
> ocm.insert(myobject);
> ...
> myobject.setFoo("dummy");
> ocm.checkout("/itsme");
> ocm.update(myobject);
> ocm.checkin(myobject);
> ...
> myobject.setFoo("lazy");
> ocm.checkout("/itsme");
> ocm.update(myobject);
> ocm.checkin(myobject);
> ...
>
> Filter f1 = qm.createFilter(MyObject.class);
> f1.addEqualTo("foo", "lazy");
> MyObject o = (MyObject) ocm.getObject(qm.createQuery(f1)); // This works!
> ...
> Filter f2 = qm.createFilter(MyObject.class);
> f2.addEqualTo("foo", "bar");
> MyObject o = (MyObject) ocm.getObject(qm.createQuery(f2)); // This returns
> "null" :(
> ...
>
> I hope someone helps me.
> Thank you,
> --
> GaS
>

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