Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Version is not being incremented in Spring mongo

I have added @Enableauditng as an annotation but @version is not incrementing the version on its own. I have @LastModifiedDate, which is being updated but not the @version.

Am i doing somehting wrong.

I am calling mongoTemplate.save(object) to againg and again.

Please advice

like image 498
neoeahit Avatar asked Oct 16 '25 17:10

neoeahit


1 Answers

I think you are using:

javax.persistence.Version 

Check your imports, @Version is part of javax.persistence (JPA) and has no relation to mongodb.

http://docs.spring.io/spring-data/mongodb/docs/1.5.0.RELEASE/reference/htmlsingle/ Unluckily, there is no hint to @Version in the spring data mongodb reference.

You should import org.springframework.data.annotation.Version for entity version information. See https://github.com/spring-projects/spring-data-mongodb/blob/1.5.x/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/PersonWithVersionPropertyOfTypeInteger.java

like image 67
Martin Baumgartner Avatar answered Oct 19 '25 06:10

Martin Baumgartner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!