我有一个实体
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
@MappedSuperclass
@ValidUuidPrimaryEntity
public class UuidPrimaryEntity implements Serializable {
private static final long serialVersionUID = 6602362437085355133L;
@Id
@Type(type = "pg-uuid")
@Column(name = "gid")
@GeneratedValue(generator = "hibernate-uuid")
@GenericGenerator(name = "hibernate-uuid", strategy = "uuid2")
private UUID id;
}
当我的实体通过JPA存储库来验证时
public class UuidPrimaryEntityValidator implements ConstraintValidator<ValidUuidPrimaryEntity, UuidPrimaryEntity > {
@Override
public void initialize(ValidUuidPrimaryEntity constraintAnnotation) {
}
@Override
public boolean isValid(UuidPrimaryEntity value, ConstraintValidatorContext context) {
return true;
}
}
id字段(value.getId())不为null。所以我无法检查实体是否是新的
ext.hibernateVersion = '5.0.2.Final'
ext.hibernateValidatorVersion = '5.2.1.Final'