Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]hibernate-annotations-3.1beta6[b]
I have annotated a method to take advantage of the Hibernate Validator.
Code:
@Column(name = "ValueType", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
@Length(max=20)
@NotNull
public String getValueType()
{
return this.valueType;
}
public void setValueType(String valueType)
{
this.valueType = valueType;
}
If I set a non-null field to null, and do a save, I get a PropertyValueException instead of an InvalidStateException. The @Length constraint is throwing an InvalidStateException like expected. I removed "nullable = false" from the @Column annotation and still got the PropertyValueException.
Is this behavior correct? I was hoping to only have to catch InvalidStateExceptions for validation errors. I don't really see the point of even having the @NonNull constraint if the PropertyValueException is going to be thrown anyways.
Thanks!