I'm using Spring Data MongoDb for backend storage and want to enable mongo auditing and it doesn't work not sure why.
I have next configuration:
@Configuration
@EnableMongoRepositories(basePackages = {"base.package"})
@EnableMongoAuditing
public class DomainConfig {
}
And I have few entities that extend my base class:
@Getter
public class Entity implements Persitable {
@Id
@Setter
protected String id;
@CreatedDate
@Setter
protected Long creationTime;
@LastModifiedDate
protected Long modificationTime;
@Version
@Setter
protected Long version;
@JsonIgnore
public boolean isNew() {
return `getVersion() == 0` && getCreationTime() == null;
}
}
But when I'm calling entityRepository.save(entity)
I'm getting NullPointerException
on line with getVersion() == 0
and getVersion()
returns null
but I think it should return 0
.
What could be the problem here?
Btw: I'm using Spring Data MongoDb 1.5.2.RELEASE version