My java application connects to CouchDB using the Ektorp persistence api http://ektorp.org/reference_documentation.html to store and retrieve objects. I'm trying to store a simple bean with few String properties and using CouchDbConnector.create(mybean) to create the document and CouchDbConnector.get(mybean.class,doumentid) to retrieve the document. When I extend my bean with CouchDBDocument as documented here http://ektorp.org/reference_documentation.html#d100e355, it works well while creating and retrieving the document but if I don't extend it with CouchDBDocument and annotate the "id" and the "revision" attributes as listed here http://ektorp.org/reference_documentation.html#d100e31, then create document works but retrieve document throws this exception.
nested exception is org.ektorp.DbAccessException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "_id"
I tried various options by changing the name "id" to "_id" but it do not work. Also, I notice that when I don't extend my bean with CouchDbDocument then in the couchdb, an "id" and "revision" fields are created in the document along with "_id" and "_rev". These fields are not created when I extend CouchDbDocument. Any idea what's wrong here?
The id field must serialize to "_id". Write a unit test and verfify that you class can be written to json and read from json with the fields named _id and _rev.