[hibernate-issues] [Hibernate-JIRA] Created: (HV-248) Validator should be aware of nested beans

Ken Egervari (JIRA) noreply at atlassian.com
Mon Oct 5 01:52:56 EDT 2009


Validator should be aware of nested beans
-----------------------------------------

                 Key: HV-248
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-248
             Project: Hibernate Validator
          Issue Type: New Feature
    Affects Versions: 4.0.0.CR1
            Reporter: Ken Egervari
            Priority: Critical


When using the Bean validation listener with Hiberante, I think the property path should be aware of nested beans.

For example, let's say we have a Customer which contains a User object. Both of these objects have validation constraints on them, however, Customer is the top-level one.

Now, if we are to save this Customer bean to hibernate with cascades, and there is an error on the User object on the field 'emailAddress', the constraint's property path is merely 'emailAddress'. 

I think this really limits what people can do with the exceptions that you are giving away, as it is very possible that the customer object also has an email address.

I realize you are giving people access to the class and target object, but what if the objects that are contained are the same type?

The right solution to this problem is the give the correct property path. In this case, the property path should really be "user.emailAddress". It should be self-aware that the user was cascaded by the customer object.

I would consider this to be critical, but as it is, it is not easy to get translate the exceptions to the Spring MVC's error handling, which requires the full path (and that makes PERFECT sense in this application). 

As it stands, all forms must only edit 1 bean at a time - no components or many-to-one relationships will work.

Thanks for listening

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list