Hello:
I've created an entity with a value object as identifier (a Roo identifierType aka a JPA @Embeddable class for using as @EmbeddedId). It has a String field with a @Size constrains, but the generated DataOnDemand doesn't try to respect this size.
Find a script below:
It creates a _Roo_DataOnDemand that follows the @Size restrictions for the fields, but not for the Embeddable's fields:Code:entity --class ~.domain.Commerce --table T_COMMERCE --identifierType ~.domain.CommerceId --testAutomatically field string --fieldName cif --column C_CIF --notNull --sizeMax 20 focus --class ~.domain.CommerceId field number --type java.lang.Integer --fieldName identifier --column C_ID --notNull field string --fieldName check --notNull --sizeMax 1 --column C_CHECK
Roo version 1.1.5 within STS on windows.Code://... public void CommerceDataOnDemand.setCif(Commerce obj, int index) { String cif = "cif_" + index; if (cif.length() > 20) { cif = cif.substring(0, 20); } obj.setCif(cif); } //... public void CommerceDataOnDemand.setEmbeddedIdClass(Commerce obj, int index) { //I miss some validations here CommerceId embeddedIdClass = new CommerceId(new Integer(index), String.valueOf(index)); obj.setId(embeddedIdClass); }
Thanks.


Reply With Quote