Problem in document fetching in couchbase lite(offline) by code

I am trying to fetch the document using view and query.
I am running and getting QueryEnumerator,
and tryin to fetch values by QueryEnumerator ref .getdocument() function,
It giving document which i have store,
At the time of storing document i have stored documet as (key , my POJO class object),
at at the time of retrieval it giving me JAVA object , i have tried to do typecasting but it is giving error as follows:

java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.kpit.ecueditor.newdtc.entity.Dtc

eventhough it should store the object in Dtc object but it is not allowing me, and i am not able to retrieve data from objecy,

Any idea what should i do?

Hi @shriram.punde,

Not sure I fully understand the issue you’re encountering. You should store the document as a set of JSON key, value pairs and when retrieving them you can deserialize the JSON as a POJO class.

Check out this blog post on using Jackson’s databind feature to automatically map the JSON to properties and vice versa.


i have another one doubt , i am deleting document from couchbase lite (offline local db) , but by sync gateway it is connected to the server , and push -pull operations are going on,
my doubt is after deleting that document is it pulled again from server or it’ll also get deleted from server?

Deleting a document creates a tombstone that’s replicated to other databases like the server. It won’t pull the document in future replications. See docs on deleting

However, if you purge the document it will pull the document from the server again in a replication that starts from the beginning. See docs on purging


got it… thank u so much :slight_smile: