4

I am using Hibernate validator for entity validation in my web-app. Hibernate tools generates the entity objects from the database schema with @Column annotation, containing 'nullable = false'.

...
@Column(name = "LANG_IDENTIFIER", nullable = false, length = 2)
public String getIdentifier() {
    return this.identifier;
}
...

Is there a way to use the validate @Column on being null? Adding '@NotNull' does the job, but this is not what I want, because then I need to change all my generated classes.

Any input would be greatly appreciated!

Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
  • 1
    nullable=false will throw (I'm guessing) a PersistenceException. In your tests you can persist an instance of the entity and assert not null or catch the exception... – user3811473 Jul 30 '14 at 09:25

0 Answers0