Closed sebastienvermeille closed 8 years ago
Please provide a minimal test project that demonstrates this behavior or show at least your two model classes (super class & sub class).
What you describe should be covered by unit test https://github.com/netceteragroup/valdr-bean-validation/blob/master/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java#L177 which uses the two classes in https://github.com/netceteragroup/valdr-bean-validation/tree/master/valdr-bean-validation/src/test/java/com/github/valdr/model/d
I investigate a bit more to determine what is really not working and it seems that just a class without any validation constraints annotation produce the error.
Exemple :
package com.mypackage.model;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NonNull;
@MappedSuperclass
@XmlRootElement
public class AbstractAuditFields {
@Getter
@NonNull
@Column(name = "CREATED_AT")
@Temporal(TemporalType.TIMESTAMP)
public Date createdAt;
@Getter
@NonNull
@Column(name = "UPDATED_AT")
@Temporal(TemporalType.TIMESTAMP)
public Date updatedAt;
@Getter
@JsonIgnore
@Column(name = "VERSION", columnDefinition = "integer DEFAULT 0", nullable = false)
@Version
public int version;
@PrePersist
void createdAt() {
this.createdAt = this.updatedAt = new Date();
}
@PreUpdate
void updatedAt() {
this.updatedAt = new Date();
}
}
I added a unit test with exactly this class https://github.com/netceteragroup/valdr-bean-validation/commit/45ea17d4bf269e00f500afa34490b96262dbd296 and it passes. I don't see the problem.
In some case we extends our model with another class. If that other class does not have any validation annotation then a NullPointExceptionOccurs breaking all the servlet ... :