Dave Bordoley wrote:
I'm having an issue using the JCouchDB binding (I hope this is an
appropriate list to ask this question???). In CouchDB I'm storing a
simple nested object like the following:
{
"var1": {
}
}
In my Java Code I'd like to map the object contained in var1 to a
specific POJO class in my outer POJO. For instance:
public class innerClass {
.
Getters/Setters
.
}
public class myClass {
public setVar1(InnerClass obj) {
...
}
}
Unfortunately no matter what I try I can't seem to get this to work. I
keep receiving the following exception the Svenson JSON library, and
from a cursory look at the code, I'm wondering if this is even
supported.
org.svenson.JSONParseException: Cannot set property media on class
contentstore.dao.MediaEntry
at org.svenson.JSONParser.parseObjectInto(JSONParser.java:357)
at org.svenson.JSONParser.parseObjectInto(JSONParser.java:389)
at org.svenson.JSONParser.parseArrayInto(JSONParser.java:283)
at org.svenson.JSONParser.parseObjectInto(JSONParser.java:399)
at org.svenson.JSONParser.parse(JSONParser.java:185)contentstore.dao.
at org.jcouchdb.db.Response.getContentAsBean(Response.java:129)
at org.jcouchdb.db.Database.queryViewInternal(Database.java:505)
at org.jcouchdb.db.Database.queryView(Database.java:365)
Any suggestions, I've tried annotated type hints, using a JSONParser,
all to no avail. Am I missing something?
Thanks for any help you can provide.
Dave
The error sounds like your class contentstore.dao.MediaEntry is not
compatible to the data you try to feed to it. Like it says it tries to
set a property named "media" on this class which for some reason doesn't
work. (wrong name? property doesn't exist?)
MediaEntry needs to either:
- declare a writeable property "media"
- use @JSONProperty to map another property to "media"
- extends AbstractDynamicProperties which would enable it to receive
any property
Regards,
Sven Helmberger