-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
iqjumps opened DATAMONGO-2139 and commented
Entity class A has Id, version and auditing fields:
@Data
@Document
public class A {
@Id String id;
@Version Long version;
@CreatedDate Date createdAt;
@LastModifiedDate Date lastModifiedAt;
}
and I tried to save new A,
ARepository.save(new A());but result document stored in mongodb doesn't have createdAt field. (only lastModifiedAt field exists)
In doInsert() in MongoTemplate, it set 0 to version field
T toSave = entity.initializeVersionProperty();and then IsNewAwareAuditingHandler checks whether entity is new using IsNewStrategy,
but version field is already set to 0, so it's not new object.
So CreatedXX fields are not touched.
I don't know it's intended
Affects: 2.1.2 (Lovelace SR2)
Issue Links:
- DATAMONGO-2128 DuplicateKeyException since upgraded to SpringBoot 2.1 when using Optimistic Locking
("is duplicated by") - DATAMONGO-2127
@CreatedDateand@CreatedByare not set anymore after upgrading Spring Boot to 2.1.0
("is duplicated by") - DATAMONGO-2179 CreatedDate is null for entities using optimistic locking via version property when saving/inserting in batch
("is duplicated by") - DATAMONGO-2150 Auditing broken for entities using optimistic locking via version properties in reactive mongo
Backported to: 2.1.3 (Lovelace SR3)
0 votes, 7 watchers
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug