It works, as long as auditing is turned off. After putting @EnableAuditing to application follows exception is thrown:
org.springframework.data.mapping.model.MappingException: Cannot determine IsNewStrategy for type class codes.walery.spring.mongo.audit.DomainWithoutAuditing!
Description:
If auditing is enabled those steps are executed:
Determine strategy to fill auditing fields
Find fields that should be filled via auditing
Fill found fields
If strategy can't be determined (because id and version is not available in domain) exception is thrown and object isn't persisted.
This exception is also thrown if you don't have any fields in model that are filled via auditing.
There is no need to throw this exception if no fields are filled via auditing.
Some code to make it clear:
// Everything fine
public class Domain1 {
@Id
Long id;
@LastModifiedDate
LocalDateTime lastModifiedDate;
String field;
}
// Exception is thrown. This is correct, there is no way to know how to fill lastModifiedDate field.
public class Domain2 {
@LastModifiedDate
LocalDateTime lastModifiedDate;
String field;
}
// Exception is thrown. But there is no reason for Exception.
public class Domain3 {
String field;
}
Care to elaborate why it makes sense to use an entity without an identifier property in the first place? The exception is in place to basically prevent accidental misconfiguration
Walery Strauch opened DATACMNS-957 and commented
Follow domain should be persist:
It works, as long as auditing is turned off. After putting
@EnableAuditing
to application follows exception is thrown:Description:
If auditing is enabled those steps are executed:
If strategy can't be determined (because id and version is not available in domain) exception is thrown and object isn't persisted.
This exception is also thrown if you don't have any fields in model that are filled via auditing.
There is no need to throw this exception if no fields are filled via auditing.
Some code to make it clear:
I've patch for this ticket.
PR: #189
Issue Links:
Referenced from: pull request #189
Backported to: 1.13 GA (Ingalls), 1.12.7 (Hopper SR7), 1.11.7 (Gosling SR7)
The text was updated successfully, but these errors were encountered: