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: Jackrabbit OCM Querying
Date Mon, 16 Mar 2009 21:41:50 GMT
2009/3/16 David Purpura <dpurpura@uci.edu>:
>
> On 3/16/09 4:01 AM, "Christophe Lombart" <christophe.lombart@gmail.com>
> wrote:
>
>> Can you give more information on your mapped class (DocumentImpl) ?
>> Which ocm version are you using ?
>
> I am using the Jackrabbit OCM 1.6 snapshot, downloaded around 6 February
> 2009.
>
> For a simple query, I would like to be able to return the DocumentImpl with
> a specified person's name (personName).
>

If you map all classes into the unstructured jcr type, you have to use
the annotation '@node' instead of  '@node(discriminator=false)'
otherwise, it will not be possible to instantiate a node to the correct class.

> However, if possible, eventually I would like to move the "personName"
> attribute into the properties Map and query for the document based on
> properties in the Map, but I am unsure of how to do this through the OCM
> QueryManager right now.
>

Query on on collection is not yet supported. It would be a nice
feature to add for the next release.




>
> <code>
> @Node(discriminator=false)
> public class DocumentImpl implements IDocument, Serializable{
>
>    @Field(path=true)
>    private String path;
>
>    @Field()
>    private String personName;
>
> @Collection
>    private Map<String, Property> properties;
>
>
>
> //http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-ocm/src/test/j
> ava/org/apache/jackrabbit/ocm/testmodel/File.java
>    @Bean
>    private File contents;
>
>    public DocumentImpl(){
>        this.properties = new HashMap<String, Property>();
>    }
>
>    // getters and setters follow
> }
>
> @Node(discriminator=false)
> public class Property {
>
>    @Field private String key;
>    @Field private String value;
>
>    public Property(){
>        this("", "");
>    }
>
>    public Property(String key, String value) {
>        super();
>        this.key = key;
>        this.value = value;
>    }
>
>    //getters and setters follow
> }
> </code>
>
> --David
>
>
>

Mime
View raw message