Announcement Announcement Module
Collapse
No announcement yet.
DataOnDemand doesn't respect the size constrains for @Embeddable IDs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DataOnDemand doesn't respect the size constrains for @Embeddable IDs

    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:
    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
    It creates a _Roo_DataOnDemand that follows the @Size restrictions for the fields, but not for the Embeddable's fields:
    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);
        }
    Roo version 1.1.5 within STS on windows.

    Thanks.

  • #2
    Hello:

    I've seen that Roo 1.1.4 wrote these validations (I've found out by comparing with a previous version of the .aj in GIT that was made by Roo 1.1.4)

    Comment

    Working...
    X