3 Replies Latest reply on Dec 19, 2006 5:45 AM by Duran David

    Repeated column in mapping for entity

    Stephen Dougall Newbie

      hi,

      We are moving from EJB2 to EJB3 so I have made a simple conversion of one of our entity beans. However I'm comming up against the following deployment problem.

      org.hibernate.MappingException: Repeated column in mapping for entity: se.benefit.uniquekey.UniqueKeyCMPData column: code (should be mapped with insert="false" update="false")
       at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575)
      ....
      


      The UniqueKeyCMPData entity bean has a composite key, there are no duplicate beans in the deployment directory so I'm not sure how there is a repeated column. Can anyone shed some light on this??

      Thanks
      Stephen

        • 1. Re: Repeated column in mapping for entity
          Maz Mohammadi Newbie

          I'm hitting the same exact problem. were there any suggestions made? Any help is greatly appreciated :)

          • 2. Re: Repeated column in mapping for entity
            Stephen Dougall Newbie

            hi,

            This problem was that I had a composite key class with a member 'user' and a setter/getter getUser(). Then in the Entity class I also had a getter/setter getUser(). This leads to duplicate column. Had to remove the getter/setter in the Entity class for it to work. Instead I now use getPrimaryKey().getuser().

            Thanks
            Stephen

            • 3. Re: Repeated column in mapping for entity
              Duran David Newbie

              Hello Stephen,
              I' m hitting the same exact problem;
              here my code:
              TermProjPK.java

              @Embeddable
              public class TermProjPK implements Serializable {
              private String auiw;
              @Column(name = "AUIS", nullable = false)
              private String auis;
              

              TermProj.java
              public class TermProj implements Serializable {
              @EmbeddedId
               private TermProjPK termProjPK;
              //jointure avec la table TermSource
               @ManyToOne
               @JoinColumn (name = "AUIW")
               private TermSource auiw;
               public TermSource getAuiw() {
               return auiw;
               }
              
               public void setAuiw(TermSource auiw) {
               this.auiw = auiw;
               }
              
              
               //jointure avec la table SnomedInter
               @ManyToOne
               @JoinColumn (name = "AUIS")
               private SnomedInter auis;
               public SnomedInter getAuis() {
               return auis;
               }
              
               public void setAuis(SnomedInter auis) {
               this.auis = auis;
               }
              @Column(name = "MODIF")
               private String modif;
              
               @Column(name = "SRC", nullable = false)
               private String src;

              TermSource.java
              public class TermSource implements Serializable {
               @Id
               @Column(name = "AUIW", nullable = false)
               private String auiw;
              @OneToMany(mappedBy="auiw")
               private Collection<TermProj> termProjs;
              
               public Collection<TermProj> getTermProjs() {
               return termProjs;
               }
              
               public void setTermProjs(Collection<TermProj> termProjs) {
               this.termProjs = termProjs;
               }

              SnomedInter.java
              public class SnomedInter implements Serializable {
              @Id
               @Column(name = "AUIS", nullable = false)
               private String auis;
              @OneToMany(mappedBy="auis")
               private Collection<TermProj> termProjs;
              
               public Collection<TermProj> getTermProjs() {
               return termProjs;
               }
              
               public void setTermProjs(Collection<TermProj> termProjs) {
               this.termProjs = termProjs;
               }
              

              I always have the same error:
              WARN [ServiceController] Problem starting service persistence.units:ear=Pharmacovigilance.ear,jar=Pharmacovigilance-ejb.jar,unitName=Pharmacovigilance-ejbPU
              org.hibernate.MappingException: Repeated column in mapping for entity: ejb.entity.TermProj column: AUIS (should be mapped with insert="false" update="false")
               at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575)
              

              my servlet of tests is as follows:
              [...]TermProjFacadeLocal termProjFacadeLocal = (TermProjFacadeLocal) lookupTermProjFacade();
              
              
              
               List news = termProjFacadeLocal.findAll();
              
              
               out.println("<TABLE align=\"center\" frame=\"border\" cellpadding=\"2\">");
               out.println("<TR style=\"color:blue\"> <TH align=\"center\" > AUIW </TH> <TH align=\"center\"> AUIS </TH> <TH align=\"center\"> MODIF </TH><TH align=\"center\"> SRC </TH></TR>");
               for (Iterator it = news.iterator(); it.hasNext();) {
               TermProj elem = (TermProj) it.next();
               out.println(" <TR> <TD> <b>" + elem.getTermProjPK().getAuiw() + " </b> </TD>");
               out.println(" <TD> <b>" + elem.getTermProjPK().getAuis() + " </b> </TD> ");
               out.println(" <TD> <b>" + elem.getModif() + " </b> </TD> ");
               out.println(" <TD> <b>" + elem.getSrc() + " </b> </TD> </TR>");
               }
               out.println("</TABLE>");
              [...]
              

              were there any suggestions made? Any help is greatly appreciated :)