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

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


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34106#action_34106 ] 

Ken Egervari commented on HV-248:
---------------------------------

Ahh, duh. That solves it nicely. Thanks ;) I never knew this constraint existed. Yeah, you can consider this one resolved ;)

I am also having another problem in that I want to validate a field, but I need to get access to other fields in order to validate it. Annotating the field only gives the validator the single value, so using a method constraint like @assertTrue is one of the only nice ways to do it. However, this causes the method to be named something different on the property path... and I'd actually like to redirect it to a field property path (because that makes a lot of sense). 

Is there any way to do this?

> 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
>            Assignee: Hardy Ferentschik
>            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