Fairly new to Hibernate Validator, but was zooming right along until I ran into a bit of a snag that I can't seem to find any info on. Neither the JSR-303 spec nor the Hibernate Validator docs mention validation behavior regarding @Transient fields. Can't find anything in the community Wiki or Jira either. Consider this:
Code:
@Entity
class SomeObject {
...
@Transient
@NotNull
private String creditCardNumber;
...
}
The use case here is that the validator is really handy when validating a form submission that binds to an object that has a creditCardNumber property. However, the creditCardNumber should never be persisted due to client security concerns with credit card storage. Unfortunately, it appears that when Hibernate persists this object, the validator is enforcing the @NotNull constraint when it seems it logically should ignore it. Does that make sense? So to rephrase, I want to use the validator to validate this bean and it's creditCardNumber only on a form submission but never when persist() is called because, well, it doesn't matter if the creditCardNumber is valid at persist() because it's not being persisted. Anyone else run into this? Thanks in advance.
-Matt