You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Gaetano Sferra <gs...@imnet.it> on 2009/01/14 17:43:11 UTC
OCM, queries and version history
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
Re: OCM, queries and version history
Posted by "g.reinhart" <gr...@googlemail.com>.
Done : https://issues.apache.org/jira/browse/JCR-1973
Regards,
Gerald Reinhart
--
View this message in context: http://www.nabble.com/OCM%2C-queries-and-version-history-tp21459838p21934062.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: OCM, queries and version history
Posted by Christophe Lombart <ch...@gmail.com>.
Sorry for the delay,
>
> I don't thing this king of code would work :
>
> QueryManager queryManager = ocm.getQueryManager();
> Filter filterChange =
> queryManager.createFilter(MyObject.class );
> filterChange.setScope( "/jcr:system/jcr:versionStrorage//");
>
>
This is not yet supported but I think it should be possible to review some
parts of the OCM implementation to support that.
If you are interested by that, please create a new Jira issue. I'm going to
go back to the OCM project in a couple of days.
Best regards,
Christophe
>
> --
> View this message in context:
> http://www.nabble.com/OCM%2C-queries-and-version-history-tp21459838p21918082.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: OCM, queries and version history
Posted by "g.reinhart" <gr...@googlemail.com>.
Christophe Lombart wrote:
>
> 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)
>
To make your own jcr query on MyObject.class classes, you can use the
QueryManager ?
I don't thing this king of code would work :
QueryManager queryManager = ocm.getQueryManager();
Filter filterChange = queryManager.createFilter(MyObject.class );
filterChange.setScope( "/jcr:system/jcr:versionStrorage//");
--
View this message in context: http://www.nabble.com/OCM%2C-queries-and-version-history-tp21459838p21918082.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: OCM, queries and version history
Posted by Christophe Lombart <ch...@gmail.com>.
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 <gs...@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
>