-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hmm,
I think this might be the bug: http://code.google.com/p/jcouchdb/issues/detail?id=48 Checked the release date: I think this fix just missed the latest release... So I will wait patiently for the next release..... Thanks, Johannes On 09/06/2010 05:14 PM, Johannes Schneider wrote: > Hi guys, > > I try to lern jcouchdb at the momemt. But I have some problems updating > documents with attachments. > That code does not work as I expected: > > > FooDocument document = new FooDocument( "foo with attachment" ); > document.setId( "daId" ); > document.addAttachment( "greeting", new Attachment( > MediaType.TEXT_PLAIN, "Hello World!".getBytes() ) ); > > db.createDocument( document ); > assertEquals( "daId", document.getId() ); > assertEquals( "Hello World!", new String( db.getAttachment( "daId", > "greeting" ) ) ); > > db.updateDocument( document ); > > { > FooDocument read = db.getDocument( FooDocument.class, "daId" ); > Attachment attachment = read.getAttachments().get( "greeting" ); > assertEquals( "2", attachment.getRevPos() ); > assertTrue( attachment.isStub() ); > > db.updateDocument( read ); //This one fails with 412 > } > > > Basically it seems to be related to the fact, that I *read* a document > with attachments and the put it again. > > > > Thanks, > > Johannes > > > > [debug] [<0.2714.0>] 'GET' /serialization_test/daId {1,1} > Headers: [{'Connection',"Keep-Alive"},{'Host',"localhost:5984"}] > [debug] [<0.2714.0>] OAuth Params: [] > [info] [<0.2714.0>] 127.0.0.1 - - 'GET' /serialization_test/daId 200 > [debug] [<0.2714.0>] 'PUT' /serialization_test/daId {1,1} > Headers: [{'Connection',"Keep-Alive"}, > {'Content-Encoding',"UTF-8"}, > {'Content-Length',"217"}, > {'Content-Type',"application/json"}, > {'Host',"localhost:5984"}] > [debug] [<0.2714.0>] OAuth Params: [] > [debug] [<0.2714.0>] Minor error in HTTP request: > {missing_stub,<<"id:daId, name:greeting">>} > [debug] [<0.2714.0>] Stacktrace: [{couch_doc,'-merge_stubs/2-fun-0-',3}, > {lists,map,2}, > {couch_doc,merge_stubs,2}, > {couch_db,prep_and_validate_update,5}, > {couch_db,'-prep_and_validate_updates/6-fun-2-',6}, > {lists,foldl,3}, > {couch_db,prep_and_validate_updates,6}, > {couch_db,update_docs,4}] > [info] [<0.2714.0>] 127.0.0.1 - - 'PUT' /serialization_test/daId 412 > [debug] [<0.2714.0>] httpd 412 error response: > {"error":"missing_stub","reason":"id:daId, name:greeting"} > - -- Johannes Schneider - blog.cedarsoft.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMhQnIAAoJEAytD9R7Qv6dcO0IANsCxfi4gY2/aNJWPWyQc1uK 04sr1YBGEGyt8haHrWVR/c0DWu8g08j+rqETic26hI5wjTAtejUTeRFvYsPn5tIH WLw9uhpOAAXPMCt+B76SooxXJn/njy/S6G+VBw81oVrG2sYearLirdNcx1XBOWPP O0pCnVkcVU7qknu/93+sKIz88BN6EhU2GnQsC+JlLs6ORgnvaDCN+CHaKm7hXR2i vFJAbOTKus3gwRlNeWYflQmjOaguB0atu+VDsZWjrz3MT8cxhPGW/Rcym9+WHKRo aoShGNucMaRXI7t4oQ3vw7o6hMoV4CqvMnNMoprmsbprtKkvoCqa1Z6Tak7iifY= =Ievk -----END PGP SIGNATURE-----
