Hibernate allows writing custom validators. I think in this specific use case, database lookup for index will be expensive and it is better to throw UncheckedException in API Implementation when the index is not found.
Here is the link to API documentation http://docs.jboss.org/hibernate/validator/4.3/reference/en-US/html_single/ Animesh > -----Original Message----- > From: Min Chen [mailto:min.c...@citrix.com] > Sent: Thursday, December 13, 2012 10:12 AM > To: cloudstack-dev@incubator.apache.org > Subject: Re: [DISCUSS] Api refactoring -- validation > > One question regarding Hibernate Validator: does it support validation of > existence of a DB entity with a given ID? The reason I am raising this > question > is that we have such a validation case in API refactoring. For example, > deployVMCmd has an input parameter "templateId", for this parameter, we > need to validate the template with the given id exists in the Template table. > Not sure if Hibernate validator supports this scenario? By glancing through > Hibernate validator doc, didn't find exact details on this, maybe I overlooked > something. > > Thanks > -min > > On 12/13/12 10:04 AM, "Fang Wang" <fang.w...@citrix.com> wrote: > > >Hibernate Validator