jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Class Cast exception
Date Tue, 06 Oct 2009 18:01:45 GMT
On Tue, Oct 6, 2009 at 19:38, Phukan, Anit <Anit_Phukan@intuit.com> 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.


Alexander Klimetschek

View raw message