On Tue, Oct 6, 2009 at 19:38, Phukan, Anit <[email protected]> wrote: > I get this exception while trying to set property value for a node to an > object > > java.lang.ClassCastException: package.objectClassname cannot be cast to > javax.jcr.Value > > In my code, I am trying to set the property value this way: > > patientRecords.setProperty("PatientObject", (Value) > persistedObject.getObject()); > > where patientRecords is a node, and persistedObject is the object
You can't store an arbitrary object as property. It has to be a javax.jcr.Value, ie. one of it's subclasses or simpler yet, using the appropriate setProperty(String name, <type> value) method. However, you can serialize your object and store it as a binary property using setProperty(String,InputStream) in JCR 1.0 or setProperty(String,Binary) in JCR 2.0. Regards, Alex -- Alexander Klimetschek [email protected]
