java - Hibernate doesn't use setter when field is null -
i want validate data before saving db (check if field not null, add matches regex in setter). if field null, hibernate doesn't use setter. should in case?
@column(name = "table_name") private string tablename; public void settablename(string tablename) { assert.hastext(tablename); // assert.hastext() - method spring util this.tablename = tablename; }
so want method assert.hastext()
throw exception if tablename null.
please, take @ hibernate docs. hibernate annotations can validate lot of cool things like: null fields, field size, etc ...
here's doc:
http://hibernate.org/validator/documentation/getting-started/
it's friendly ;)
Comments
Post a Comment