3 Replies Latest reply on Jul 10, 2009 4:36 PM by Lhyna Rojas

    Issues with relationships between tables

    Lhyna Rojas Newbie

      Hi All, I'm experiencing some difficulties with my first seam application and maybe you could help me. I'm trying to do reverse engineering from my data model.
      I have an entity named persona(people) which has an id, last_name, doc type, blood type, birth place, and id expedition place  (I removed other fields trying to figure it out).

      I also have an entity named cte (constant) which has an id and a name, and finally an entity dvp (political division) with an id and a name.

      The relation between this tables are as follow persona.doc_type=cte.id, persona.blood_type=cte.id, persona.birth_place=dvp.id and persona.id_expedition_place=dvp.id.

      I'm using reverse engineering from jboss developer studio, and when I try to create a new record of persona the following error appear.






      Caused by: java.lang.Error: Unresolved compilation problems:
           Duplicate field PersonaHome.cteHome
           Duplicate field PersonaHome.cteHome

        • 1. Re: Issues with relationships between tables
          Arbi Sookazian Master

          You need to be much more specific with more details.


          How exactly did you do your revengr?  I usually use seam generate-entities from cmd line.  I do not use SAF, so no EntityHome or EntityQuery, etc.  I prefer a clean revengr and then use SMPC with Hibernate Manual flush for all my SFSBs.


          What RDBMS are you using?  If you're using SQL SERVER, then you will need to instruct hbm2java (part of Hibernate Tools to revengr your data model) to add the @GeneratedValue annotation for IDENTITY columns.


          And what exactly did you do to generate that error?  Was that via the EntityManager API to persist a new entity into the table?

          • 2. Re: Issues with relationships between tables
            Lhyna Rojas Newbie

            Hi!


            I did revengr using jboss developer studio from a RDBMS MySQL. I couldn't do revengr from cmd because the issue in My Link. Maybe that wasn't an issue at all. :$


            The revengr works fine, it creates all the classes and the relations between tables, but the table persona has many relationships with the table cte (because cte is the table in which almost all the values that may appear at comboboxes are) and many relationships with the table dvp (table of states and cities), and persona (people) has the city wher him/her live, where was born and many others.


            The problem seems to be related to the fact that the same bean is used to modify, add the relationships between persona form and cte form.


            Thanks,




            • 3. Re: Issues with relationships between tables
              Lhyna Rojas Newbie

              I just realize that in the file PersonaHome.java located at org.domain.sigee.entity has been built as follow



              package org.domain.sigee.entity;
              
              import java.util.ArrayList;
              import java.util.List;
              import org.jboss.seam.annotations.In;
              import org.jboss.seam.annotations.Name;
              import org.jboss.seam.framework.EntityHome;
              
              @Name("personasHome")
              public class PersonasHome extends EntityHome<Personas> {
                  @In(create = true)
                  CtesHome ctesHome;
                  @In(create = true)
                  CtesHome ctesHome;
                  @In(create = true)
                  CtesHome ctesHome;
                  @In(create = true)
                  DvpsHome dvpsHome;
                  @In(create = true)
                  DvpsHome dvpsHome;
                  @In(create = true)
                  DvpsHome dvpsHome;
                  @In(create = true)
                  CtesHome ctesHome;...
              


              And the issue is related at the instance names, so I changed it to



              package org.domain.sigee.entity;
              
              import java.util.ArrayList;
              import java.util.List;
              import org.jboss.seam.annotations.In;
              import org.jboss.seam.annotations.Name;
              import org.jboss.seam.framework.EntityHome;
              
              @Name("personasHome")
              public class PersonasHome extends EntityHome<Personas> {
              
                  @In(create = true)
                  CtesHome ctesHome1;
                  @In(create = true)
                  CtesHome ctesHome2;
                  @In(create = true)
                  CtesHome ctesHome3;
                  @In(create = true)
                  DvpsHome dvpsHome;
                  @In(create = true2)
                  DvpsHome dvpsHome;
                  @In(create = true)
                  DvpsHome dvpsHome3;
                  @In(create = true)
                  CtesHome ctesHome4;...
              


              But isn't that simple, does it? (I tried to change to almost all the code at PersonaHome where I find ctesHome ) now I'm getting this error


              18:22:27,175 ERROR [application] javax.faces.el.EvaluationException: org.jboss.seam.RequiredException: In attribute requires non-null value: personasHome.ctesHome2
              javax.faces.el.EvaluationException: javax.faces.el.EvaluationException: org.jboss.seam.RequiredException: In attribute requires non-null value: personasHome.ctesHome2
              



              Anywhere else the code has to be changed?