Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-2400

GAE - ROO Auto-generates code for fields marked as @Transient

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Complete
    • Affects Version/s: 1.1.3.RELEASE, 1.1.4.RELEASE
    • Fix Version/s: 1.1.4.RELEASE
    • Component/s: GAE, PERSISTENCE
    • Labels:
      None
    • Environment:
      1.1.4.BUILD-SNAPSHOT [rev a87267a]

      Description

      I have a class with the following fields:

          @Transient private Type type;
          @Transient private Category category;
          @Transient private SubCategory subCategory;
      

      I do not want ROO to generate persistence code for them, but although they are marked as transient, ROO still generated the following:

      Image_Roo_JavaBean.aj

          private Long Image._typeId;
          
          private Long Image._categoryId;
          
          private Long Image._subCategoryId;
      
         public Type Image.getType() {
              if (this._typeId != null) {
                  if (this.type == null || this.type.getId() != this._typeId) {
                      this.type = Type.findType(this._typeId);
                  }
              } else {
                  this.type = null;
              }
              return this.type;
          }
          
          public void Image.setType(Type type) {
              if (type != null) {
                  if (type.getId () == null) {
                      type.persist();
                  }
                  this._typeId = type.getId();
              } else {
                  this._typeId = null;
              }
              this.type = type;
          }
          
          public Long Image.getCategoryId() {
              return this.categoryId;
          }
          
          public void Image.setCategoryId(Long categoryId) {
              this.categoryId = categoryId;
          }
          
          public Category Image.getCategory() {
              if (this._categoryId != null) {
                  if (this.category == null || this.category.getId() != this._categoryId) {
                      this.category = Category.findCategory(this._categoryId);
                  }
              } else {
                  this.category = null;
              }
              return this.category;
          }
          
          public void Image.setCategory(Category category) {
              if (category != null) {
                  if (category.getId () == null) {
                      category.persist();
                  }
                  this._categoryId = category.getId();
              } else {
                  this._categoryId = null;
              }
              this.category = category;
          }
          
          public Long Image.getSubCategoryId() {
              return this.subCategoryId;
          }
          
          public void Image.setSubCategoryId(Long subCategoryId) {
              this.subCategoryId = subCategoryId;
          }
          
          public SubCategory Image.getSubCategory() {
              if (this._subCategoryId != null) {
                  if (this.subCategory == null || this.subCategory.getId() != this._subCategoryId) {
                      this.subCategory = SubCategory.findSubCategory(this._subCategoryId);
                  }
              } else {
                  this.subCategory = null;
              }
              return this.subCategory;
          }
          
          public void Image.setSubCategory(SubCategory subCategory) {
              if (subCategory != null) {
                  if (subCategory.getId () == null) {
                      subCategory.persist();
                  }
                  this._subCategoryId = subCategory.getId();
              } else {
                  this._subCategoryId = null;
              }
              this.subCategory = subCategory;
          }
      

      The problem with this is that when I persist my class, I get 3 irrelevant properties in my datastore that are causing me grief.

      As a workaround, I tried adding my own getters and setters to the class. This would be ok, but it still generates just the fields:

          private Long Image._typeId;
          
          private Long Image._categoryId;
          
          private Long Image._subCategoryId;
      

      How do I get it to stop?

        Attachments

          Activity

            People

            Assignee:
            jtyrrell James Tyrrell
            Reporter:
            sdmurphy Scott Murphy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: