[hibernate-issues] [Hibernate-JIRA] Commented: (HV-16) Validator ignores components

Rene Parra (JIRA) noreply at atlassian.com
Fri Nov 7 18:47:15 EST 2008


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

Rene Parra commented on HV-16:
------------------------------

Possible work around is the following:
Annotate the entity with a "fake property" that exposes the component's property.

For example:
Assume the following:
* Assume Entity "A" has component "B".
* "B" has a property "fooProp" that we wish to annotate with a Hibernate Validator constraint.

Because of HV-16, we cannot annotate B.fooProp because it will be ignored.
Possible workaround is -- create a "fake property" that exposes "fooProp" on entity A; then annotate A.fooProp.

public class A ... {
   // assume these methods because B is a component of A
   private B;
   public B getB();

   @Length(max=255)
   public T getFooProp() {
       return getB().getFooProp();
   }
}

All the regular setters/getters can be on B. 

I did not test this on schema generation. This was only tested with Hibernate Validator for insert/update precondition testing.  Also the errors will be on A (not on the component B), so special mapping must be done if this is to be reported in the UI.

This has the added benefit that when HV-16 is fixed, the migration should be fairly straightforward.


> Validator ignores components
> ----------------------------
>
>                 Key: HV-16
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-16
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: engine
>            Reporter: Emmanuel Bernard
>


-- 
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