Announcement Announcement Module
Collapse
No announcement yet.
Pluralization error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pluralization error

    I am getting a "Could not determine the plural name" error in the final line of the following script.

    Code:
    project --topLevelPackage com.myco.testapp --projectName testapp
    persistence setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT
    enum type --class ~.reference.AuditEventType
    enum constant --name SomeEventType
    enum constant --name AnotherEventType
    entity --class ~.base.AuditEvent
    field date --fieldName ts --notNull --class ~.base.AuditEvent --type java.util.Date
    field ref --fieldName eventType --notNull --type ~.reference.AuditEventType
    field string --fieldName description --notNull
    controller all --package ~.web
    The exact error is

    Could not determine the plural name for the 'eventType' field in AuditEvent
    So, I added added a @RooPlural("eventTypes") above the eventType field in the AuditEvent class, but continue to get the same message.

    Thanks in advance for any help.

    Todd

  • #2
    This seems like a bug to me. I believe the issue is that the plural support is currently only available for entities (not enum types). Can you please raise a Jira ticket for this?

    Comment


    • #3
      Raised ROO-526

      Comment


      • #4
        Hi guys!
        I'm getting the same error while running a *.roo script and the main problem is that it stops script execution...
        I mean, if it can skip this error, make a warning and log it in a file for later review , we can write the correct pluralization ...

        I'll try changing the fieldname to avoid this as a workaround...

        I'll post this comment on jira

        BTW, the word that raises the problem is "idioma" that as you may guess it's in spanish...(it means "language")

        Comment


        • #5
          Newbie error (In my case)

          It seems it was a newbie fault....
          I was wrong specifying the class packages...I've rewritten the script with fully specified package names and it works fine!

          You can see the detail in jira

          Comment


          • #6
            I believe the problem is you are treating the enum as an entity... Try this and tell us how it goes

            Code:
            enum type --class ~.reference.AuditEventType
            enum constant --name SomeEventType
            enum constant --name AnotherEventType
            entity --class ~.base.AuditEvent
            field date --fieldName ts --notNull --class ~.base.AuditEvent --type java.util.Date
            field enum --fieldName eventType --type ~.reference.AuditEventType --notNull --enumType STRING
            field string --fieldName description --notNull
            controller all --package ~.web

            Comment


            • #7
              Originally posted by toddwh50 View Post
              Raised ROO-526
              For the link lovers: http://jira.springframework.org/browse/ROO-526

              Hopefully this will be fixed in the 1.0.1 release?

              Comment


              • #8
                Originally posted by andrews View Post
                Hopefully this will be fixed in the 1.0.1 release?
                Here in the Roo team we have a rule-of-thumb that before any release all bugs with a Jira number are either resolved OR we cannot action them for some reason (eg most commonly we're waiting on the user to give us more details, or it's a bug in an external project etc). This is one reason people can depend on Roo. We don't ship when there are known bugs and the ball is in our court to fix them.

                Comment


                • #9
                  Thanks Ben, that's good to know. Not every open source project is so responsive.

                  Comment


                  • #10
                    Just to reiterate what I have just commented in the ROO-526 Jira ticket:

                    As @ jeduan mentioned in his message above. this is not a bug. Using 'field enum' rather than 'field reference' is the expected use of this command in your case. Currently bot the 'field reference' and the 'field set' commands expect target types which are marked as JPA @Entity. I have reflected this in the current trunk (rev 572) by checking target types to be @Entity. This will hopefully make it clearer to the user. We may relax this rule in upcoming versions of Roo to make things a little more flexible when we accommodate additional persistence mechanisms other than JPA.

                    The field reference and field set command expect JPA @Entity types as their referenced type and the field enum command is meant to handle references to enum types.

                    I hope this clears up how enum types can be handled.

                    Comment


                    • #11
                      I'm getting the same error as the original post and I'm not using any enums. The error reads "Could not determine the plural name for the 'fund' field in Client" So I put @RooPlural(value="funds") on the funds field and tried to generate controllers using the command ~.domain.Client roo> controller scaffold --class com.company.mis.control.ClientController --entity com.company.mis.domain.Client

                      I am on version 1.0.2

                      Comment


                      • #12
                        Can you post your ~.domain.Client and ~.domain.Fund classes?

                        Comment


                        • #13
                          I don't have @RooEntity on the Fund class.. could that be an issue?


                          Client
                          Code:
                          package com.mycompany.mis.Domain;
                          
                          import java.io.Serializable;
                          import javax.persistence.Basic;
                          import javax.persistence.CascadeType;
                          import javax.persistence.Column;
                          import javax.persistence.Entity;
                          import javax.persistence.Id;
                          import javax.persistence.JoinColumn;
                          import javax.persistence.ManyToOne;
                          import javax.persistence.NamedQueries;
                          import javax.persistence.NamedQuery;
                          import javax.persistence.OneToOne;
                          import javax.persistence.Table;
                          import javax.persistence.UniqueConstraint;
                          import org.springframework.roo.addon.entity.RooEntity;
                          import org.springframework.roo.addon.plural.RooPlural;
                          
                          
                          /**
                           *
                           * @author ds
                           */
                          @Entity
                          @RooEntity
                          @Table(name = "Client", uniqueConstraints = {
                              @UniqueConstraint(columnNames = {"Name"}),
                              @UniqueConstraint(columnNames = {"Number"})})
                          @NamedQueries({
                              @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c")})
                          public class Client implements Serializable {
                              private static final long serialVersionUID = 1L;
                              @Id
                              @Basic(optional = false)
                              @Column(name = "Id", nullable = false)
                              private Integer id;
                              @Column(name = "Number", length = 10)
                              private String number;
                              @Column(name = "ParentClientId")
                              private Integer parentClientId;
                              @Basic(optional = false)
                              @Column(name = "Name", nullable = false, length = 125)
                              private String name;
                              @Basic(optional = false)
                              @Column(name = "ShortName", nullable = false, length = 25)
                              private String shortName;
                              @OneToOne(cascade = CascadeType.ALL, mappedBy = "clientId")
                              @RooPlural(value="funds")
                              private Fund fund;
                              @JoinColumn(name = "ClientGroupId", referencedColumnName = "Id")
                              @ManyToOne
                              private ClientGroup clientGroup;
                              @JoinColumn(name = "OriginatorId", referencedColumnName = "Id")
                              @ManyToOne
                              private Employee originator;
                              @JoinColumn(name = "PartnerInChargeId", referencedColumnName = "Id")
                              @ManyToOne
                              private Employee partnerInCharge;
                              @JoinColumn(name = "BillerInChargeId", referencedColumnName = "Id")
                              @ManyToOne
                              private Employee billerInCharge;
                              @JoinColumn(name = "ManagerId", referencedColumnName = "Id")
                              @ManyToOne
                              private Employee manager;
                          
                              public Client() {
                              }
                          
                              public Client(Integer id) {
                                  this.id = id;
                              }
                          
                              public Client(Integer id, String name, String shortName) {
                                  this.id = id;
                                  this.name = name;
                                  this.shortName = shortName;
                              }
                          
                              public Integer getId() {
                                  return id;
                              }
                          
                              public void setId(Integer id) {
                                  this.id = id;
                              }
                          
                              public String getNumber() {
                                  return number;
                              }
                          
                              public void setNumber(String number) {
                                  this.number = number;
                              }
                          
                              public Integer getParentClientId() {
                                  return parentClientId;
                              }
                          
                              public void setParentClientId(Integer parentClientId) {
                                  this.parentClientId = parentClientId;
                              }
                          
                              public String getName() {
                                  return name;
                              }
                          
                              public void setName(String name) {
                                  this.name = name;
                              }
                          
                              public String getShortName() {
                                  return shortName;
                              }
                          
                              public void setShortName(String shortName) {
                                  this.shortName = shortName;
                              }
                          
                              public Fund getFund() {
                                  return fund;
                              }
                          
                              public void setFund(Fund fund) {
                                  this.fund = fund;
                              }
                          
                              public ClientGroup getClientGroup() {
                                  return clientGroup;
                              }
                          
                              public void setClientGroup(ClientGroup clientGroup) {
                                  this.clientGroup = clientGroup;
                              }
                          
                              public Employee getOriginatorId() {
                                  return originator;
                              }
                          
                              public void setOriginator(Employee originator) {
                                  this.originator = originator;
                              }
                          
                              public Employee getPartnerInCharge() {
                                  return partnerInCharge;
                              }
                          
                              public void setPartnerInCharge(Employee partnerInCharge) {
                                  this.partnerInCharge = partnerInCharge;
                              }
                          
                              public Employee getBillerInCharge() {
                                  return billerInCharge;
                              }
                          
                              public void setBillerInCharge(Employee billerInCharge) {
                                  this.billerInCharge = billerInCharge;
                              }
                          
                              public Employee getManager() {
                                  return manager;
                              }
                          
                              public void setManager(Employee manager) {
                                  this.manager = manager;
                              }
                          
                              @Override
                              public int hashCode() {
                                  int hash = 0;
                                  hash += (id != null ? id.hashCode() : 0);
                                  return hash;
                              }
                          
                              @Override
                              public boolean equals(Object object) {
                                  // TODO: Warning - this method won't work in the case the id fields are not set
                                  if (!(object instanceof Client)) {
                                      return false;
                                  }
                                  Client other = (Client) object;
                                  if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                                      return false;
                                  }
                                  return true;
                              }
                          
                              @Override
                              public String toString() {
                                  return "com.mycompany.MIS.Domain.Client[id=" + id + "]";
                              }
                          
                          }

                          Comment


                          • #14
                            Fund
                            Code:
                            /*
                             * To change this template, choose Tools | Templates
                             * and open the template in the editor.
                             */
                            
                            package com.mycompany.mis.Domain;
                            
                            import java.io.Serializable;
                            import java.util.List;
                            import javax.persistence.Basic;
                            import javax.persistence.CascadeType;
                            import javax.persistence.Column;
                            import javax.persistence.Entity;
                            import javax.persistence.Id;
                            import javax.persistence.JoinColumn;
                            import javax.persistence.JoinTable;
                            import javax.persistence.ManyToMany;
                            import javax.persistence.ManyToOne;
                            import javax.persistence.NamedQueries;
                            import javax.persistence.NamedQuery;
                            import javax.persistence.OneToOne;
                            import javax.persistence.Table;
                            import javax.persistence.UniqueConstraint;
                            
                            /**
                             *
                             * @author ds
                             */
                            @Entity
                            @Table(name = "Fund", uniqueConstraints = {
                                @UniqueConstraint(columnNames = {"ClientId"})})
                            @NamedQueries({
                                @NamedQuery(name = "Fund.findAll", query = "SELECT f FROM Fund f")})
                            public class Fund implements Serializable {
                                private static final long serialVersionUID = 1L;
                                @Id
                                @Basic(optional = false)
                                @Column(name = "Id", nullable = false)
                                private Integer id;
                                @Column(name = "FundStartupId")
                                private Integer fundStartupId;
                                @Column(name = "FundTerminationId")
                                private Integer fundTerminationId;
                                @JoinTable(name = "FundInvestmentTypes", joinColumns = {
                                    @JoinColumn(name = "FundId", referencedColumnName = "Id", nullable = false)}, inverseJoinColumns = {
                                    @JoinColumn(name = "InvestmentTypeId", referencedColumnName = "Id", nullable = false)})
                                @ManyToMany
                                private List<InvestmentType> investmentTypes;
                                @OneToOne(cascade = CascadeType.ALL, mappedBy = "fund")
                                private FundStaffing fundStaffing;
                                @OneToOne(cascade = CascadeType.ALL, mappedBy = "fund")
                                private FundTermination fundTermination;
                                @OneToOne(cascade = CascadeType.ALL, mappedBy = "fund")
                                private FundStartup fundStartup;
                                @JoinColumn(name = "ClientId", referencedColumnName = "Id", nullable = false)
                                @OneToOne(optional = false)
                                private Client client;
                                @JoinColumn(name = "FundActiveStatusId", referencedColumnName = "Id")
                                @ManyToOne
                                private FundActiveStatus fundActiveStatus;
                                @JoinColumn(name = "FundDifficultyLevelId", referencedColumnName = "Id")
                                @ManyToOne
                                private FundDifficultyLevel fundDifficultyLevel;
                                @JoinColumn(name = "InvestmentMethodId", referencedColumnName = "Id")
                                @ManyToOne
                                private FundInvestmentMethod investmentMethod;
                                @JoinColumn(name = "FundStrategyId", referencedColumnName = "Id")
                                @ManyToOne
                                private FundStrategy fundStrategy;
                            
                                public Fund() {
                                }
                            
                                public Fund(Integer id) {
                                    this.id = id;
                                }
                            
                                public Integer getId() {
                                    return id;
                                }
                            
                                public void setId(Integer id) {
                                    this.id = id;
                                }
                            
                                public Integer getFundStartupId() {
                                    return fundStartupId;
                                }
                            
                                public void setFundStartup(Integer fundStartupId) {
                                    this.fundStartupId = fundStartupId;
                                }
                            
                                public Integer getFundTerminationId() {
                                    return fundTerminationId;
                                }
                            
                                public void setFundTerminationId(Integer fundTerminationId) {
                                    this.fundTerminationId = fundTerminationId;
                                }
                            
                                public List<InvestmentType> getInvestmentTypes() {
                                    return investmentTypes;
                                }
                            
                                public void setInvestmentTypes(List<InvestmentType> investmentTypes) {
                                    this.investmentTypes = investmentTypes;
                                }
                            
                                public FundStaffing getFundStaffing() {
                                    return fundStaffing;
                                }
                            
                                public void setFundStaffing(FundStaffing fundStaffing) {
                                    this.fundStaffing = fundStaffing;
                                }
                            
                                public FundTermination getFundTermination() {
                                    return fundTermination;
                                }
                            
                                public void setFundTermination(FundTermination fundTermination) {
                                    this.fundTermination = fundTermination;
                                }
                            
                                public FundStartup getFundStartup() {
                                    return fundStartup;
                                }
                            
                                public void setFundStartup(FundStartup fundStartup) {
                                    this.fundStartup = fundStartup;
                                }
                            
                                public Client getClientId() {
                                    return client;
                                }
                            
                                public void setClientId(Client clientId) {
                                    this.client = clientId;
                                }
                            
                                public FundActiveStatus getFundActiveStatusId() {
                                    return fundActiveStatus;
                                }
                            
                                public void setFundActiveStatusId(FundActiveStatus fundActiveStatusId) {
                                    this.fundActiveStatus = fundActiveStatusId;
                                }
                            
                                public FundDifficultyLevel getFundDifficultyLevelId() {
                                    return fundDifficultyLevel;
                                }
                            
                                public void setFundDifficultyLevelId(FundDifficultyLevel fundDifficultyLevelId) {
                                    this.fundDifficultyLevel = fundDifficultyLevelId;
                                }
                            
                                public FundInvestmentMethod getInvestmentMethodId() {
                                    return investmentMethod;
                                }
                            
                                public void setInvestmentMethodId(FundInvestmentMethod investmentMethodId) {
                                    this.investmentMethod = investmentMethodId;
                                }
                            
                                public FundStrategy getFundStrategyId() {
                                    return fundStrategy;
                                }
                            
                                public void setFundStrategyId(FundStrategy fundStrategyId) {
                                    this.fundStrategy = fundStrategyId;
                                }
                            
                                @Override
                                public int hashCode() {
                                    int hash = 0;
                                    hash += (id != null ? id.hashCode() : 0);
                                    return hash;
                                }
                            
                                @Override
                                public boolean equals(Object object) {
                                    // TODO: Warning - this method won't work in the case the id fields are not set
                                    if (!(object instanceof Fund)) {
                                        return false;
                                    }
                                    Fund other = (Fund) object;
                                    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                                        return false;
                                    }
                                    return true;
                                }
                            
                                @Override
                                public String toString() {
                                    return "com.mycompany.MIS.Domain.Fund[id=" + id + "]";
                                }
                            
                            }

                            Comment


                            • #15
                              I believe I have resolved this issue. It was caused by an incorrect mappedBy property in my @ManyToMany and @OneToOne annotations. My Fund class does not have "clientId" as private variable, rather it has
                              Code:
                              @OneToOne(optional = false) private Client client;
                              Client
                              Code:
                                  @OneToOne(cascade = CascadeType.ALL, mappedBy = "clientId")
                                  @RooPlural(value="funds")
                                  private Fund fund;
                              should be

                              Code:
                                  @OneToOne(cascade = CascadeType.ALL, mappedBy = "client")
                                  private Fund fund;

                              Comment

                              Working...
                              X