This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Data Cassandra 4.4.0!spring-doc.cn

Auditing Configuration for Cassandra

To activate auditing functionality, create a configuration as the following example shows:spring-doc.cn

Activating auditing through configuration
@Configuration
@EnableCassandraAuditing
class Config {

  @Bean
  public AuditorAware<AuditableUser> myAuditorProvider() {
      return new AuditorAwareImpl();
  }
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
  xsi:schemaLocation="
    http://www.springframework.org/schema/data/cassandra
    https://www.springframework.org/schema/data/cassandra/spring-cassandra.xsd
    http://www.springframework.org/schema/beans
    https://www.springframework.org/schema/beans/spring-beans.xsd">

    <cassandra:auditing mapping-context-ref="customMappingContext" auditor-aware-ref="yourAuditorAwareImpl"/>
</beans>

If you expose a bean of type AuditorAware to the ApplicationContext, the auditing infrastructure picks it up automatically and uses it to determine the current user to be set on domain types. If you have multiple implementations registered in the ApplicationContext, you can select the one to be used by explicitly setting the auditorAwareRef attribute of @EnableCassandraAuditing.spring-doc.cn

To enable auditing, leveraging a reactive programming model, use the @EnableReactiveCassandraAuditing annotation.
If you expose a bean of type ReactiveAuditorAware to the ApplicationContext, the auditing infrastructure picks it up automatically and uses it to determine the current user to be set on domain types. If you have multiple implementations registered in the ApplicationContext, you can select the one to be used by explicitly setting the auditorAwareRef attribute of @EnableReactiveCassandraAuditing.spring-doc.cn

Example 1. Activating reactive auditing using JavaConfig
@Configuration
@EnableReactiveCassandraAuditing
class Config {

  @Bean
  public ReactiveAuditorAware<AuditableUser> myAuditorProvider() {
      return new AuditorAwareImpl();
  }
}