Hello,
I'm using hibernate's mechanism for validation of objects fields. Thus I have to specify my constraints as annotations in the bean class. Example:
Code:
@NotEmpty
@Length(max = 250)
public String getName() {
return name;
}
Unfortunately this happens to be a problem for me because:
- From my point of view I want to have a single configuration source for everything concerning hibernate managed objects - this is - OR mapping, links, validation, predefined named queries etc. This of course should be *.hbm.xml file. If this is possible I can generate everything automatically - database schema, beans, DAO, etc.
- I need to keep my object's java code as simple and plain as possible - Pojo (Note: PLAIN with capital letters). This will help me share this object in client side and other modules (I'm OSGi based), without having to worry about the dependent libraries.
So I want to be able to set my validation constraints, using meta data in the *.hbm.xml.
I know I can do this my self, creating a custom event listener, which uses custom meta data from hbm.xml, does the validation, throws exception if necessary, etc. But I think such a feature can be part of the hibernate framework. I believe this will be useful for a lot of people.
What do you think ?