java - Spring data version annotation not incrementing when used on a mongo collection -


i using spring data mongodb store binary data such images etc want maintain version field append url cheat browser caching images.

see document base class below:

import org.springframework.data.annotation.id; import org.springframework.data.annotation.version; import org.springframework.data.mongodb.core.index.indexed;  public abstract class basedocument {      @id     @indexed(unique=true)     protected long id;     protected byte[] data;     protected string mimetype;     protected string filename;     protected string extension;     @version     private long version; 

i have repository wrapping mongooperations saving documents.

import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.repository;  @repository public class documentrepository implements idocumentrepository {      @autowired     private mongooperations mongotemplate;      @override     public <d extends basedocument> void savedocument(d document) {         mongotemplate.save(document);     } 

in attempt implement versioning, did hunting around , found there @version annotation spring mongo deprecated. discovered spring data @version annotation should used instead. went ahead , used spring data @version annotation.

what expect happen version field incremented every time save document. overwriting same document several times version field not getting incremented expecting.

am doing incorrectly or there additional need do?

in order use @version annotation need enable auditing in spring data mongodb adding 1 line application context:

<mongo:auditing /> 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -