So I was able to resolve this issue, and am writing down the solution if some hapless soul happens to encounter something similar in the future.
The trick is - the child node type should extend "nt:unstructured". Hope it helps someone out there. -------- anirban -----Original Message----- From: Anirban Majumdar [mailto:[email protected]] Sent: Monday, January 18, 2010 7:52 PM To: [email protected] Subject: ObjectContentManager Persisting Child Nodes Hello, After searching high and low for a solution to my problem, I've finally thought of writing in. Even though the subject might suggest that this problem must've been faced by some other people too, but I couldn't find any similar issues discussed. Probably I'm just making some simple mistake :/ Anyways, the problem I face is like this - I have a node structure like: ------------------------------------------------------------------------ ---------------- [av:ContentType] > nt:base, mix:referenceable, mix:lockable - av:name (string) mandatory - av:user (string) - av:version (double) + av:metadata (av:ContentMetadataType) = av:ContentMetadataType multiple [av:ContentMetadataType] - av:metadataName (string) - av:metadataId (string) mandatory - av:value ------------------------------------------------------------------------ ---------------- Using annotated Java POJO classes I'm trying to persist the data for a Content type. The annotations I've added to my Content and ContentMetadata POJO classes are as follows: ------------------------ Content.java ------------------------ @Field (uuid = true) private String id; @Field (jcrName = "av:name") private String name; @Field (jcrName = "av:user") private String user; @Field (jcrName = "av:version") private double version; @Collection (jcrElementName = "av:metadata", jcrName = "av:name", jcrType = "av:ContentMetadataType") private List<ContentMetadata> assocMetatadata; @Field (path = true) private String path = "/av:content"; ------------------------ ContentMetadata.java ------------------------ @Field (jcrName = "av:metadataId") String metadataId; @Field (jcrName = "av:metadataName") String metadataName; @Field (jcrName = "av:value") String value; @Field (path = true) String path = "/av:content/av:metadata"; ------------------------------------------------------------------------ ----------------------------------------------------------------------- Now, when I try to persist an instance of Content.java using OCM, I keep encountering the following exception: ---------------------------- javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {http://av.com/vault}metadata ---------------------------- Any assistance to solve this problem is much appreciated. Thanks, -------- anirban
