Announcement Announcement Module
Collapse
No announcement yet.
Roo not detecting methods from superclass Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo not detecting methods from superclass

    I have an abstract base entity class which is annotated with @MappedSuperclass and used as the superclass for @Entity objects like so:


    Code:
    @MappedSuperclass
    @RooJavaBean
    @RooToString
    public abstract class AbstractEntity implements Serializable {
    
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_GENERATOR")
        @Column(name = "ID", length = 10, unique = true, updatable = false, nullable = false)
        private Long id;
    
        @Version
        @NotNull
        @Column(name = "UPDATE_DATE", length = 7, nullable = false)
        private Timestamp updateDate = new Timestamp(new Date().getTime());
    
        @NotNull
        @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "CREATE_DATE", length = 7, nullable = false)
        private Date createDate;
    
        public Long getId() {
            return id;
        }
    
        public void setId(Long id) {
            this.id = id;
        }
    
        public Timestamp getUpdateDate() {
            return updateDate;
        }
    
        public void setUpdateDate(Timestamp updateDate) {
            this.updateDate = updateDate;
        }
    }
    @
    Code:
    Entity
    @RooEntity
    @RooJavaBean
    @RooToString
    @Table(schema = "ENVAUDIT", name = "EA_RANK")
    @SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "ENVAUDIT.EA_RANK_S")
    @AttributeOverride(name="id", column=@Column(name = "EA_RANK_ID", length = 10, unique = true, updatable = false, nullable = false))
    public class Rank extends AbstractEntity {
    
        @NotNull
        @Size(max = 2)
        @Column(name = "EA_RANK_CODE", length = 2, nullable = false)
        private String code;
    
        @NotNull
        @Size(max = 4000)
        @Column(name = "EA_RANK_DESC", length = 4000, nullable = false)
        private String description;
    }
    Code:
    @Entity
    @RooEntity
    @RooJavaBean
    @RooToString
    @Table(schema = "ENVAUDIT", name = "EA_CYCLE")
    @SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "ENVAUDIT.EA_CYCLE_ID_SEQ")
    @AttributeOverride(name="id", column=@Column(name = "CYCLE_ID", length = 10, unique = true, updatable = false, nullable = false))
    public class Cycle extends AbstractEntity {
    
        @NotNull
        @Size(max = 100)
        @Column(name = "CYCLE_DESC", length = 100, nullable = false)
        private String description;
    
        @NotNull
        @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "CYCLE_BEGIN_DATE", length = 7, nullable = false)
        private Date beginDate;
    
        @NotNull
        @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "CYCLE_END_DATE", length = 7, nullable = false)
        private Date endDate;
    
        @NotNull
        @Column(name = "CYCLE_ACTIVE_IND", length = 1, nullable = false)
        @Type(type="yes_no")
        private Boolean active;
    }
    Given this setup Roo is showing the following error message:
    User provided @javax.persistence.Id field but failed to provide a public 'getId()' method in 'Rank'

    I believe this error might also be preventing Roo from updating other generated files. For instance I have added the modifyCycle method to my CycleDataOnDemand.java file and Roo has not removed the the corresponding method from the CycleDataOnDemand_Roo_DataOnDemand.aj file.

    I wasn't sure if this was a bug in Roo or something I am doing wrong so I didn't create an issue in Jira.

    Note: Without adding the modifyCycle() method to the .java file all of the integration tests passed when doing "mvn clean test".

    Note: I am using Roo version 1.0.0.M1 because my organization's proxy or virus scanner is blocking me from downloading the prepared zip files and I have to make a special request to our networks team to get the files so I have been holding off for now because of the hassle (perhaps until RC1).

  • #2
    Hi Chris,

    Thanks for reporting this issue. I have, unfortunately, not been able to replicate this exactly but it appears to be a problem in Roo. Can you open a Jira ticket and describe the exact steps you have taken to get to the stage where Roo reports "User provided @javax.persistence.Id field but failed to provide a public 'getId()' method in 'Rank''. Ideally you switch on 'development mode' before running the command to see what the exception is and attach that to the Jira ticket.

    I would like to know when exactly you have used the Roo shell to generate code artefacts and when you edited the code by hand. So a step by step guide (including the exact commands you issued) detailing your actions to get to this stage would help. If you can it would also be helpful if you can attach your project to the Jira ticket.

    Regards,
    Stefan

    Comment


    • #3
      Sorry, I was recently hit with a lot of work, both at work (new projects) and at home (fixing up my house to sell it). I will have to try to recreate the project since I forget my steps in setting it up.

      I probably created the AbstractEntity, Rank, and Cycle using Roo. Then, added the id, updateDate, and createDate fields to AbstractEntity along with the corresponding annotations manually. Then, added the fields to Rank and Cycle using Roo. After that, I would have added the @Column and @Type annotations to the newly added fields manually.

      I will try to find some time to try this again and document my steps, as well as turning on development mode. I don't think I should open a Jira ticket until I am able to do this, as I might find I am not able to replicate the problem again either.

      Comment

      Working...
      X