java - Hibernate issue - Repeated column in mapping for entity -


i keep facing "repeated column in mapping entity: com.ts.user.entity.tutrptlocyearly column: locid (should mapped insert="false" update="false")" issue whenever running unit test. seeking , advice fix problem, tried hard fix issue, error keep happen?

below situation

i created 2 tables, tut_location (primary key: locid) , tut_rpt_loc_yearly (primary key: locid + year, foreign key: locid). using eclipse jpa tools, generated 3 class me, tutlocation.java, tutrptlocyearly , tutrptlocyearlypk.

enter image description here

tutlocation.java

    @entity @table(name="tut_location") @namedquery(name="tutlocation.findall", query="select t tutlocation t") public class tutlocation extends initentity implements serializable {     private static final long serialversionuid = 1l;      @id     private integer locid;      private string name;      //bi-directional many-to-one association tutrptlocyearly     @onetomany(mappedby="tutlocation", cascade={cascadetype.all})     private list<tutrptlocyearly> tutrptlocyearlies;      public tutlocation() {     }      public integer getlocid() {         return this.locid;     }      public void setlocid(integer locid) {         this.locid = locid;     }      public string getname() {         return this.name;     }      public void setname(string name) {         this.name = name;     }      public list<tutrptlocyearly> gettutrptlocyearlies() {         return this.tutrptlocyearlies;     }      public void settutrptlocyearlies(list<tutrptlocyearly> tutrptlocyearlies) {         this.tutrptlocyearlies = tutrptlocyearlies;     }      public tutrptlocyearly addtutrptlocyearly(tutrptlocyearly tutrptlocyearly) {         gettutrptlocyearlies().add(tutrptlocyearly);         tutrptlocyearly.settutlocation(this);          return tutrptlocyearly;     }      public tutrptlocyearly removetutrptlocyearly(tutrptlocyearly tutrptlocyearly) {         gettutrptlocyearlies().remove(tutrptlocyearly);         tutrptlocyearly.settutlocation(null);          return tutrptlocyearly;     } } 

tutrptlocyearly.java

    @entity @table(name="tut_rpt_loc_yearly") @namedquery(name="tutrptlocyearly.findall", query="select t tutrptlocyearly t") public class tutrptlocyearly extends initentity implements serializable {     private static final long serialversionuid = 1l;      @embeddedid     private tutrptlocyearlypk id;      private timestamp lastupdate;      private integer notrans;      //bi-directional many-to-one association tutlocation     @manytoone(cascade={cascadetype.all}, fetch=fetchtype.lazy)     @joincolumn(name="locid")     private tutlocation tutlocation;      public tutrptlocyearly() {     }      public tutrptlocyearlypk getid() {         return this.id;     }      public void setid(tutrptlocyearlypk id) {         this.id = id;     }      public timestamp getlastupdate() {         return this.lastupdate;     }      public void setlastupdate(timestamp lastupdate) {         this.lastupdate = lastupdate;     }      public integer getnotrans() {         return this.notrans;     }      public void setnotrans(integer notrans) {         this.notrans = notrans;     }      public tutlocation gettutlocation() {         return this.tutlocation;     }      public void settutlocation(tutlocation tutlocation) {         this.tutlocation = tutlocation;     }  } 

tutrptlocyearlypk.java

@embeddable public class tutrptlocyearlypk implements serializable {     //default serial version id, required serializable classes.     private static final long serialversionuid = 1l;      @column(insertable=false, updatable=false)     private integer locid;      private integer year;      public tutrptlocyearlypk() {     }     public integer getlocid() {         return this.locid;     }     public void setlocid(integer locid) {         this.locid = locid;     }     public integer getyear() {         return this.year;     }     public void setyear(integer year) {         this.year = year;     }      public boolean equals(object other) {         if (this == other) {             return true;         }         if (!(other instanceof tutrptlocyearlypk)) {             return false;         }         tutrptlocyearlypk castother = (tutrptlocyearlypk)other;         return              this.locid.equals(castother.locid)             && this.year.equals(castother.year);     }      public int hashcode() {         final int prime = 31;         int hash = 17;         hash = hash * prime + this.locid.hashcode();         hash = hash * prime + this.year.hashcode();          return hash;     } } 

error message:

caused by: org.hibernate.mappingexception: repeated column in mapping entity: com.ts.user.entity.tutrptlocyearly column: locid (should mapped insert="false" update="false") @ org.hibernate.mapping.persistentclass.checkcolumnduplication(persistentclass.java:830) @ org.hibernate.mapping.persistentclass.checkpropertycolumnduplication(persistentclass.java:848) @ org.hibernate.mapping.persistentclass.checkcolumnduplication(persistentclass.java:870) @ org.hibernate.mapping.persistentclass.validate(persistentclass.java:605) @ org.hibernate.mapping.rootclass.validate(rootclass.java:265) @ org.hibernate.boot.internal.metadataimpl.validate(metadataimpl.java:329) @ org.hibernate.boot.internal.sessionfactorybuilderimpl.build(sessionfactorybuilderimpl.java:443) @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.build(entitymanagerfactorybuilderimpl.java:879) ... 46 common frames omitted


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -