2009/3/16 David Purpura <[email protected]>:
>
> On 3/16/09 4:01 AM, "Christophe Lombart" <[email protected]>
> 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
>
>
>