Issue with using @manytomany and detailview

namrata
2014-04-28
2014-04-30
  • namrata

    namrata - 2014-04-28

    hi,
    I have two tables namely,dept_master and emp_master
    dept_master:company_id,dept_id(pk),dept_name
    emp_master:company_code,emp_code(pk),emp_name,emp_dob,emp_doj
    i joined the two table using the annotations @manytomany and @joincolumn
    BUt i keep getting error as follows:
    SEVERE: Servlet.service() for servlet jsp threw exception
    org.openxava.util.ElementNotFoundException: The reference department does not exist in EmployeeClass
    at org.openxava.model.meta.MetaModel.getMetaReference(MetaModel.java:396)
    at org.openxava.model.meta.MetaModel.getMetaReference(MetaModel.java:393)
    at org.openxava.web.WebEditors.getEditorURLDescriptionsList(WebEditors.java:266)
    at org.apache.jsp.xava.editors.listEditor_jsp._jspService(listEditor_jsp.java:792)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    my entity classes are as follows:
    EmployeeClass.java
    @Tab(properties="empCode,empName,department.deptName,empDob",
    baseCondition="select e.empCode,e.empName,d.deptName,e.empDob"+" from EmployeeClass e,DepartmentClass d"+" where e.companyCode=d.companyId and e.deptCode=d.deptId")
    @Table(name="Emp_Master")
    public class EmployeeClass implements Serializable
    {
    private static final long serialVersionUID = 1L;
    private String companyCode;
    private String empCode;
    private String empName;
    private String deptCode;
    private String empDob;
    private String empDoj;
    private Set department;
    public EmployeeClass()
    {

    }
    public EmployeeClass(String companyCode,String empCode, String empName, String deptCode,String empDob, String empDoj, Set<DepartmentClass> department)
    {

    this.companyCode=companyCode;
    this.empCode = empCode;
    this.empName = empName;
    this.deptCode=deptCode;
    this.empDob=empDob;
    this.empDoj = empDoj;
    this.department = new HashSet<DepartmentClass>();
    

    }
    @Id
    @Column(name="emp_code",length=10)
    public String getEmpCode() {
    return this.empCode;
    }
    public void setEmpCode(String empCode) {
    this.empCode = empCode;
    }
    @Column(name="emp_name",length=30)
    public String getEmpName() {
    return this.empName;
    }
    public void setEmpName(String empName) {
    this.empName = empName;
    }
    @Column(name="emp_dob",length=9)
    public String getEmpDob()
    {
    return this.empDob;
    }
    public void setEmpDob(String empDob) {
    this.empDob = empDob;
    }
    @Column(name="emp_doj",length=9)
    public String getEmpDoj()
    {
    return this.empDoj;
    }
    public void setEmpDoj(String empDoj)
    {
    this.empDoj = empDoj;
    }
    @ManyToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "company_code",referencedColumnName="company_id",insertable=false,updatable=false)
    public Set getDepartment()
    {
    return this.department;
    }
    public void setDepartment(Set department) {
    this.department = department;
    }
    @Column(name="dept_code",length=10)
    public String getDeptCode() {
    return deptCode;
    }
    public void setDeptCode(String deptCode) {
    this.deptCode = deptCode;
    }
    @Column(name="company_code",length=10)
    public String getCompanyCode()
    {
    return companyCode;
    }
    public void setCompanyCode(String companyCode)
    {
    this.companyCode = companyCode;
    }
    DepartmentClass.java
    @Entity
    @Table(name="Dept_Master")
    public class DepartmentClass implements Serializable
    {
    private static final long serialVersionUID = 1L;

    private String companyId;
    private String deptId;
    private String deptName;
    private Set<EmployeeClass> empl;

    public DepartmentClass()
    {

    }
    public DepartmentClass(String companyId,String deptId, String deptName, Set<EmployeeClass> empl)
    {
    this.companyId=companyId;
    this.deptId = deptId;
    this.deptName = deptName;
    this.empl=new HashSet<EmployeeClass>();
    }

    @Id
    @Column(name="dept_id",length=10)
    public String getDeptId()
    {
    return this.deptId;
    }

    public void setDeptId(String deptId)
    {
    this.deptId = deptId;
    }

    @Column(name="dept_name",length=20)
    public String getDeptName()
    {
    return this.deptName;
    }

    public void setDeptName(String deptName)
    {
    this.deptName = deptName;
    }

    @ManyToMany(fetch=FetchType.EAGER,mappedBy="department",targetEntity=org.openxav.payroll.module.EmployeeClass.class)
    public Set<EmployeeClass> getEmpl()
    {
    return this.empl;
    }

    public void setEmpl(Set<EmployeeClass> empl)
    {
    this.empl = empl;
    }

    @Column(name="company_id",length=10)
    public String getCompanyId() {
    return this.companyId;
    }
    public void setCompanyId(String companyId) {
    this.companyId = companyId;
    }
    On the other Hand when i used @ManytoOne on employee and @onetomany on department.I keep getting error as : more than one row with the given identifier was found
    in this case i get a proper view except when i click on details mode it shows system error and shows no data int textboxes and in stacktrace it shows:Impossible to do the EmployeeClass search.
    Please help me with this issue..

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks