Hi Nikolaos, No, you're not missing anything. JSR-303 (validation) is on the list for the next major version of Stripes. That will really simplify things as Hibernate already supports JSR-303. When I get some time I plan on working on that but it may be a little while because I haven't really had any extra time lately. :-(
Aaron On 05/13/2010 11:43 PM, Nikolaos Giannopoulos wrote: > Hi, > > I'm integrating Stripersist w/ JPA, Hibernate and MySQL and have been > working with some code from Frederic's great book. > > Assuming the following shortened class excerpts: > > @Entity > public class Contact extends BaseModel { > private String firstName; > ... > > public class ContactFormActionBean { > @ValidateNestedProperties( { > @Validate(field = "firstName", maxlength = 25), > ... > @Override > public void setContact(Contact contact) { > super.setContact(contact); > } > > The above logically results in a Contact table "firstName" column that > is varchar(255) which is obviously not ideal and moreover will not be > required as the field is never> than 25. > > Now to make the Contact table "firstName" column varchar(25) vs. the > default varchar(255) I add the following @Column annotation and all is well: > > @Entity > public class Contact extends BaseModel { > @Column(length=25) > private String firstName; > ... > > Except now I have 2 values that I need to keep in sync PER field that is > constrained (and typically a high percentage of String fields do not > need to be 255 chars). > > So what to do about this to simplify the duplication issue i.e. the > constraints at the Model and Controller? Well the obvious traditional > coding choice is something like: > > @Entity > public class Contact extends BaseModel { > public static final int FIRST_NAME_LENGTH = 25; > > @Column(length=Contact.FIRST_NAME_LENGTH) > ... > private String firstName; > ... > > public class ContactFormActionBean { > @ValidateNestedProperties( { > @Validate(field = "firstName", maxlength = > Contact.FIRST_NAME_LENGTH), > ... > @Override > public void setContact(Contact contact) { > super.setContact(contact); > } > > Now this keeps the values in sync but PER each 2 properties I want to > keep in sync I am introducing 1 additional variable (constant) to > configure. In some ways better but still feels lacking.... > > Is there an easier way to solve this issue such that it better leverages > Stripes forte of convention over configuration? > > Perhaps I am missing something obvious? > > --Nikolaos > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Stripes-users mailing list > Stripes-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/stripes-users > > ------------------------------------------------------------------------------ _______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users