Skip to content

@version field value ignored when updating data [DATAREST-1329] #1689

Description

@spring-projects-issues

asifbakht opened DATAREST-1329 and commented

I have a model with field @version annotation. When data is sent with wrong version number to service it goes through different process and a proper version is set to model payload content. That should not be the case, version should not be controlled by spring framework but it should throw exception if user send wrong version number (higher or lower from current record version in database).

 

I investigated and debug on RepositoryEntityController and verified that @version field sent from client side is ignored before saving content into database.

 

Before RepositoryEntityController the payload content is passed to PersistentEntityResource where it fetches the existing record from database and merge new content into old record.

 

After going more deeply I found that DomainObjectReader class function doWithPersistentProperty modifies old record content with new content one but ignores version field and let the old version remain intact.  

If this is scenario then it will never throw Optimisitc Lock exception

 

Between I am using spring-data-rest-webmvc-2.6.7 with MongoDB


Affects: 3.1.3 (Lovelace SR3)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions