My some code here:
  public static void updateCardReviewInCouchBase(CardReviewInfoDocument 
entity) {
        try {
            Database db = DBController.getInstance().getCouchDatabase();
            if (db != null) {
                try {
                    Log.e("TAG", "updateCardReviewInCouchBase: " + 
entity.getId());
                    entity.save(db, new 
AbstractDocument.OnDocumentPersistenceListener() {
                        @Override
                        public void onBeforeSave(Map<String, Object> 
properties) {
                            Log.e("TAG", "onBeforeSave:properties:" + 
properties.toString());
                        }

                        @Override
                        public void onAfterSave(Document document) {
                            Log.e("TAG", "onAfterSave:properties:" + 
document.getProperties().toString());
                        }
                    });
                } catch (CouchbaseLiteException e) {
                    db.clearDocumentCache();
                    entity.save(db);
                }
            }
        } catch (CouchbaseLiteException e) {
            e.printStackTrace();
        }
    }

update method:
     public final void save(Database database, 
OnDocumentPersistenceListener callback) throws CouchbaseLiteException {
        if (callback != null) {
            callback.onBeforeSave(mProperties);
        }
        // Create document if required
        if (mDocument == null) {
            mDocument = database.createDocument();
        }
        // com.couchbase.lite.CouchbaseLiteException: Conflicts not allowed 
and there is already an existing doc with id: 
1180a204-bddd-4ea8-9070-5b24fd17f2de
        mDocument.putProperties(mProperties);

        if (callback != null) {
            callback.onAfterSave(mDocument);
        }
    }

在 2014年11月7日星期五UTC+8上午9时45分06秒,Traun Leyden写道:
>
> Can you produce some standalone code that reproduces the problem?
>
>
>
> On Thu, Nov 6, 2014 at 5:42 PM, peng liu <[email protected] <javascript:>> 
> wrote:
>
>> I think problem is  case by update same document  twice ? and at second 
>> times ,the first is not really update in couchbase ,so when i try update 
>> again ,it will crash ????
>>
>> 在 2014年11月7日星期五UTC+8上午9时24分35秒,peng liu写道:
>>
>>> Hi.I use couchbase on android.
>>> But some times when i  update my doc .it will crash.
>>> *11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr 
>>> <http://com.eusoft.recite.fr> W/System.err﹕ 
>>> com.couchbase.lite.CouchbaseLiteException: Conflicts not allowed and there 
>>> is already an existing doc with id: 4cd9f17d-f28f-48c9-8866-eec3a9cabe35*
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.couchbase.lite.Database.putRevision(Database.java:3480)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.couchbase.lite.Database.putRevision(Database.java:3415)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.couchbase.lite.Document.putProperties(Document.java:415)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.couchbase.lite.Document.putProperties(Document.java:250)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.eusoft.recite.support.entities.AbstractDocument.
>>> save(AbstractDocument.java:58)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.eusoft.recite.support.entities.AbstractDocument.
>>> save(AbstractDocument.java:44)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.eusoft.recite.support.ReciteSupportController.
>>> updateCardReviewInCouchBase(ReciteSupportController.java:417)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.eusoft.recite.support.ReciteSupportController.answerCard(
>>> ReciteSupportController.java:815)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> com.eusoft.recite.activity.recite.ReciteActivity$5.run(
>>> ReciteActivity.java:170)
>>> 11-07 09:19:51.440    9487-9562/com.eusoft.recite.fr W/System.err﹕ at 
>>> java.lang.Thread.run(Thread.java:841)
>>>
>>> and how to fix it ?
>>> i found this issues:https://github.com/couchbase/couchbase-lite-java-
>>> core/issues/97#issuecomment-62040966
>>> but i have try to clean the document cache,it will crash again.
>>> * Database db = DBController.getInstance().getCouchDatabase();*
>>> *            if (db != null) {*
>>> *                try {*
>>> *                    entity.save(db);*
>>> *                } catch (CouchbaseLiteException e) {*
>>> *                    db.clearDocumentCache();*
>>> *                    entity.save(db);*
>>> *                }*
>>> *            }*
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Couchbase Mobile" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/mobile-couchbase/b0ffe551-50e0-4ccc-b665-326e42a2f32e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/mobile-couchbase/b0ffe551-50e0-4ccc-b665-326e42a2f32e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/02560d05-5972-444e-8999-08c9616515c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to