Skip to content

Spring @Version optimistic locking annotation is unsupported #51

@DinkoTontchev

Description

@DinkoTontchev

To easily reproduce, modify com.redis.om.spring.annotations.document.fixtures.Company to add a Spring @Version annotation like so:

  @Version
  Long version;

then run your existing test com.redis.om.spring.annotations.document.BasicRedisDocumentMappingTest:testAuditAnnotations()
and observe the following error:

org.springframework.dao.DuplicateKeyException: Cannot insert existing object with id 01G5MB6GH63J2JKTWEZXN6J5WC!. Please use update.

It seems your implementation of CRUD repository is not updating the version field therefore causing the spring method deciding wether an object isNew to treat current as new since version = null.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions