Results 1 to 2 of 2

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

  1. #1
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default 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. #2
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •