Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Pluralization error

  1. #11
    Join Date
    Mar 2010
    Posts
    12

    Default

    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

  2. #12
    Join Date
    Nov 2009
    Location
    Mexico City, Mexico
    Posts
    13

    Default

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

  3. #13
    Join Date
    Mar 2010
    Posts
    12

    Default

    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 + "]";
        }
    
    }

  4. #14
    Join Date
    Mar 2010
    Posts
    12

    Default

    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 + "]";
        }
    
    }

  5. #15
    Join Date
    Mar 2010
    Posts
    12

    Default

    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;

  6. #16

    Default

    hello,
    I started to play with roo this week, so far really impressed.
    Thanks for this great piece of software.

    I faced a problem with plural, and as this thread is about that, I am posting it here.

    I have an entity class called Corpus, plural is Corpora.
    Issue #1:
    When I generate entity Corpus with fields, finder list gives:
    findCorpusesByName, etc.
    Ok, I read this thread and added RooPlural("Corpora") annotation by hand in Corpus.java and Roo shell picked it up, so I was able to add finder findCorporaByName.
    The problem is my log.roo script cannot be executed at once, since initially I cannot add finder findCorporaByName.
    It would be good, if one could specify plural inside entity command, something like: entity --class x.y.z.Corpus --plural Corpora, so correct spelled finders are automatically generated.

    Issue #2:
    If I had executed contoller all, before I added RooPlural, CorpusController.java does not pick up the change, namely, it remains:

    @RequestMapping(params = "form", method = RequestMethod.GET)
    public String CorpusController.createForm(ModelMap modelMap) {
    modelMap.addAttribute("corpus", new Corpus());
    return "corpuses/create";
    }

    So, I deleted complete controller package and src/main/webapp, executed controller all again and now I see coprora instead of corpuses in my CorpusController.

    I guess this is not so important but wanted to report anyway.

    thanks again & best,
    milan

  7. #17
    Join Date
    Oct 2010
    Location
    Almere, The Netherlands
    Posts
    32

    Default

    Following entity results in the plural error when trying to create a controller.
    Could not determine plural for 'MyObject'

    Code:
    @RooJavaBean
    @RooToString
    @RooEntity
    public class MyObject {
    
        @Min(-10L)
        @Max(10L)
        private Integer abc;
    }
    First of all it would be nice if the error message would give you the name of the field which is preventing it from creating the controller.

    The plural problem is caused by the @Min annotation with the negative value. Is the annotation like this incorrect or is this a bug?

Tags for this Thread

Posting Permissions

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