-
Notifications
You must be signed in to change notification settings - Fork 100
Closed
Milestone
Description
Problem
RevisionType retrieved from revision metadata is always unknown.
Cause
EnversRevisionRepositoryImpl.getRevisionMetadata()
always returns an AnnotationRevisionMetadata object with an old constructor which passes UNKNOWN type to the new constructor in AnnotationRevisionMetadata.
Solution
Use of new constructor in AnnotationRevisionMetadata in EnversRevisionRepositoryImpl.java getRevisionMetadata
.
EnversRevisionRepositoryImpl.java
/**
* Returns the {@link RevisionMetadata} wrapper depending on the type of the given object.
*
* @param object
* @return
*/
private RevisionMetadata<?> getRevisionMetadata(Object object) {
return object instanceof DefaultRevisionEntity //
? new DefaultRevisionMetadata((DefaultRevisionEntity) object) //
: new AnnotationRevisionMetadata<N>(object, RevisionNumber.class, RevisionTimestamp.class);
}
AnnotationRevisionMetadata.java -> old constructor
/**
* Creates a new {@link AnnotationRevisionMetadata} inspecting the given entity for the given annotations. If no
* annotations will be provided these values will not be looked up from the entity and return {@literal null}. The
* revisionType will be set to {@literal unknown}
*
* @param entity must not be {@literal null}.
* @param revisionNumberAnnotation must not be {@literal null}.
* @param revisionTimeStampAnnotation must not be {@literal null}.
*/
public AnnotationRevisionMetadata(Object entity, Class<? extends Annotation> revisionNumberAnnotation,
Class<? extends Annotation> revisionTimeStampAnnotation) {
this(entity, revisionNumberAnnotation, revisionTimeStampAnnotation, RevisionType.UNKNOWN);
}
AnnotationRevisionMetadata.java -> new constructor
/**
* Creates a new {@link AnnotationRevisionMetadata} inspecting the given entity for the given annotations. If no
* annotations will be provided these values will not be looked up from the entity and return {@literal null}.
*
* @param entity must not be {@literal null}.
* @param revisionNumberAnnotation must not be {@literal null}.
* @param revisionTimeStampAnnotation must not be {@literal null}.
* @param revisionType must not be {@literal null}.
* @since 2.2.0
*/
public AnnotationRevisionMetadata(Object entity, Class<? extends Annotation> revisionNumberAnnotation,
Class<? extends Annotation> revisionTimeStampAnnotation, RevisionType revisionType) {
Assert.notNull(entity, "Entity must not be null!");
Assert.notNull(revisionNumberAnnotation, "Revision number annotation must not be null!");
Assert.notNull(revisionTimeStampAnnotation, "Revision time stamp annotation must not be null!");
Assert.notNull(revisionType, "Revision Type must not be null!");
this.entity = entity;
this.revisionNumber = detectAnnotation(entity, revisionNumberAnnotation);
this.revisionDate = detectAnnotation(entity, revisionTimeStampAnnotation);
this.revisionType = revisionType;
}
blaketastic2, ISKU and kaikun213
Metadata
Metadata
Assignees
Labels
No labels