Annotation @EnableDynamoDBAuditing is not working properly
Expected Behavior
Persist the current logged user in the Dynamodb table.
Actual Behavior
It is not possible to get the user inside the class annotated with @DynamoDBTable or @DynamoDBDocument.
Steps to Reproduce the Problem
- I annotated my DynamodbConfig (
@Configuration) class with@EnableDynamoDBAuditing(auditorAwareRef = "auditorProvider", modifyOnCreate = true, setDates = true); - I created a method (named
auditorProvider()) and annotated it with@Bean. This method returnsorg.springframework.data.domain.AuditorAware; - I tried to save my document (repository.save -
DynamoDBCrudRepository) and no data related to user and dates are saved in the Dynamodb table.
Specifications
- Spring Data DynamoDB Version: 5.0.2
- Spring Data Version: 2.0.8.RELEASE
- AWS SDK Version: 1.11.336
- Java Version: 1.8
- Platform Details: Linux (Ubuntu)
May related to #169
@derjust,
Just a couple more information to help in this issue.
I missed some annotations (for Dynamodb) to use the @EnableDynamoDBAuditing properly such as:
@CreatedBy
@LastModifiedBy
@CreatedDate
@LastModifiedDate
Of course, it is impossible to use those annotations, because they are available only for Entities (@Entity).
I found an annotation (@DynamoDBAutoGeneratedTimestamp) in AWS SDK that I can substitute @CreatedDate and @LastModifiedDate. I only need to define DynamoDBAutoGenerateStrategy (CREATE or ALWAYS).
Unfortunately, I can't use org.springframework.data.annotation.CreatedBy and org.springframework.data.annotation.LastModifiedBy and AWS SDK does not provided any annotations.
I think that the issue #169 is different from this one, because the 169's author is trying to use DynamoDB Auditing with Entities. I mean that he is assuming that DynamoDB Auditing works, and I guess that DynamoDB Auditing is not working.
Thanks.
Is that to say that @EnableDynamoDBAuditing currently doesn't actually do anything in any circumstance?
After more inspection of the code, I can see that this does actually add "modifiedBy" and "modifiedDate" just fine as long as you have an AuditibleAware bean defined. It doesn't seem to add created date or created by currently (at least, I couldn't get that to work).
Those annotations are in spring-commons-data, which is a part of spring data, so they're definitely not only available for entities.