You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by duncanm <du...@gr-tech.net> on 2008/03/27 19:37:57 UTC

OCM Collection Mapping

Is there any documentation which explains how to map child nodes using OCM?

I have tried the following and it does not work. When I load a Folder, the
children property is null - no proxy is set so I cannot get to its children.

I have had to create my own grt:Container and grt:Node types so that the SNS
constraint is properly respected - but that is another story.

Can anyone tell me what is wrong?

@Node(jcrType="grt:Container", jcrMixinTypes = "mix:referenceable", extend =
Content.class)
public class Folder extends Content {
	
	@Collection(
				proxy = true, 
				autoUpdate = false, 
				autoInsert = false, 
				autoRetrieve = true, 
				elementClassName = Content.class, 
				jcrSameNameSiblings = false
	)
	protected List children;

	public List getChildren() {
		return children;
	}

	public void setChildren(List children) {
		this.children = children;
	}

}

with

@Node(jcrType="grt:Node", isAbstract=true)
public abstract class Content {
	
	@Field(path=true) String path;
	@Field(jcrName="grt:name") String title; 
	@Field(jcrName="grt:startDate") Date startDate;
	@Field(jcrName="grt:endDate") Date endDate;
	@Field(jcrName="grt:creator") Integer creator;
	@Field(jcrName="grt:modifier") Integer modifier;
	@Field(jcrName="grt:status") Integer status = 0;
	@Field(uuid=true) private String uuid; 
	
    @Bean(converter=ParentBeanConverterImpl.class)
    protected Folder parentFolder;
    
	public Folder getParentFolder() {
		return parentFolder;
	}
	public void setParentFolder(Folder parentFolder) {
		this.parentFolder = parentFolder;
	}
	public String getUuid() {
		return uuid;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

...
... etc
}
-- 
View this message in context: http://www.nabble.com/OCM-Collection-Mapping-tp16330951p16330951.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: OCM Collection Mapping

Posted by Christophe Lombart <ch...@gmail.com>.
After a first reading, it looks fine.
Are sure that the creation was good ?

In the unit tests, you can fin  something similar to this case.
Christophe


On Thu, Mar 27, 2008 at 7:37 PM, duncanm <du...@gr-tech.net> wrote:
>
>  Is there any documentation which explains how to map child nodes using OCM?
>
>  I have tried the following and it does not work. When I load a Folder, the
>  children property is null - no proxy is set so I cannot get to its children.
>
>  I have had to create my own grt:Container and grt:Node types so that the SNS
>  constraint is properly respected - but that is another story.
>
>  Can anyone tell me what is wrong?
>
>  @Node(jcrType="grt:Container", jcrMixinTypes = "mix:referenceable", extend =
>  Content.class)
>  public class Folder extends Content {
>
>         @Collection(
>                                 proxy = true,
>                                 autoUpdate = false,
>                                 autoInsert = false,
>                                 autoRetrieve = true,
>                                 elementClassName = Content.class,
>                                 jcrSameNameSiblings = false
>         )
>         protected List children;
>
>         public List getChildren() {
>                 return children;
>         }
>
>         public void setChildren(List children) {
>                 this.children = children;
>         }
>
>  }
>
>  with
>
>  @Node(jcrType="grt:Node", isAbstract=true)
>  public abstract class Content {
>
>         @Field(path=true) String path;
>         @Field(jcrName="grt:name") String title;
>         @Field(jcrName="grt:startDate") Date startDate;
>         @Field(jcrName="grt:endDate") Date endDate;
>         @Field(jcrName="grt:creator") Integer creator;
>         @Field(jcrName="grt:modifier") Integer modifier;
>         @Field(jcrName="grt:status") Integer status = 0;
>         @Field(uuid=true) private String uuid;
>
>     @Bean(converter=ParentBeanConverterImpl.class)
>     protected Folder parentFolder;
>
>         public Folder getParentFolder() {
>                 return parentFolder;
>         }
>         public void setParentFolder(Folder parentFolder) {
>                 this.parentFolder = parentFolder;
>         }
>         public String getUuid() {
>                 return uuid;
>         }
>         public void setUuid(String uuid) {
>                 this.uuid = uuid;
>         }
>
>  ...
>  ... etc
>  }
>  --
>  View this message in context: http://www.nabble.com/OCM-Collection-Mapping-tp16330951p16330951.html
>  Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>