Oh, and as for the exception message - this is really important.
Let's say I have an object called Employer, and I'm writing a test and I forget to set it's name. It's *ME* that made the mistake... not some code or something else. Employer also has about 40 other properties on it.
So, I go to the run the test, and then I get this:
Code:
org.hibernate.validator.InvalidStateException: validation failed for: jawbs.domain.employer.Employer
at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:148)
at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:172)
at org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:142)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:65)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
Wow... what a fantastic exception. It tells me nothing other than that employer has an error in it. How many? I dunno. Which properties? Who knows?
Seriously, InvalidStateException should throw something more useful. Imagine if it actually iterated through InvalidValues[] array and just told me what it was? If it did that, I could just add employer.setName( "abc" );... and presto! - My test would pass!
This gets worse when multiple properties are not set. The programmer is in the freaking dark.
I think this definitely warrants a change - this is not productive in the least. Every other framework in existence usually has better exception messages than this, unless it's some parser error that's delegating to a library.
The point is that *I* as a developer shouldn't have to call into anything else to get this information. I really just want to read it, make the change and rerun the test. Simple.