If there is an entity mapped to the CouchDB without the recommended "_rev" property, the following sequence will raise an EntityAlreadyExistsException:
Session s = openSession();
s.beginTransaction();
MyEntity me = new MyEntity();
me.setId( "foobar-1" );
me.setDescription( "Foo" );
s.persist( me );
s.flush();
me.setDescription( "Bar" );
s.getTransaction().commit();
The revision value created by the database is not kept around in the tuple snapshot created by the insert, so the update will appear as an INSERT. |