- 
                Notifications
    You must be signed in to change notification settings 
- Fork 310
Closed
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.comtype: documentationA documentation updateA documentation update
Milestone
Description
Hi, people
I'm trying to use Cassandra Auditing as I'm used to do while using spring-data-jpa but it isn't woking.
The field annotated with @CreatedDate is not being filled but @LastModifiedDate works normally.
To verify this behavior I used a docker image starting it with the command below
 docker run --name cassandra-local -p 9042:9042  -d cassandra:latest
Then I ran this application
package com.example.datacassandra;
import java.time.Instant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.cassandra.config.EnableCassandraAuditing;
import org.springframework.data.cassandra.core.mapping.Column;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.Table;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@SpringBootApplication
@EnableCassandraAuditing
@EnableCassandraRepositories
public class DataCassandraApplication {
	public static void main(String[] args) {
		SpringApplication.run(DataCassandraApplication.class, args);
	}
}
@Table("my_table_test")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
class MyTest{
	@PrimaryKey
	private String key;
	@CreatedDate
	@Column("created_date")
	private Instant createdDate;
	@LastModifiedDate
	@Column("last_modified_date")
	private Instant lastModifiedDate;
}
interface MyTestRepository extends CrudRepository<MyTest,String>{}
@Component
class DataConfig implements CommandLineRunner{
	@Autowired
	private MyTestRepository repository;
	@Override
	public void run(String... args) throws Exception {
		repository.deleteAll();
		repository.save(MyTest.builder()
			.key("My Awesome key " )
		.build());
	}
}
Then I checked the database using cqlsh inside the running Cassandra container, but created date is null
cqlsh:my_test> select * from my_table_test ;
nicolasmoura and lackovic
Metadata
Metadata
Assignees
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.comtype: documentationA documentation updateA documentation update