java - Spring JPA Hibernate duplicate -


hi new world. making own application spring jpa hibernate. have entity class. works duplicates attributes. code this:

import java.util.date;  import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.joincolumn; import javax.persistence.manytoone; import javax.validation.constraints.notnull;      @entity     public class event {          @id         @generatedvalue         private integer id;          public integer getid() {             return id;         }          @column(nullable = false)         public void setid(integer id) {             this.id = id;         }          /*------------------------------ title ------------------------*/         private string title;         @column(nullable = false)         public string gettitle() {             return title;         }          @column(nullable = false)         public void settitle(string title) {             this.title = title;         }          /* [note] have 2 ids : event_id, eventid          - these not case of duplication. */         /*------------------- event_id -----------------------------*/         private string event_id;          public string getevent_id() {             return event_id;         }          public void setevent_id(string event_id) {             this.event_id = event_id;         }      /*-------------- eventid -------------------------------------*/         @column(unique = true)         private string eventid;          public string geteventid() {             return eventid;         }          public void seteventid(string eventid) {             this.eventid = eventid;         }            /*------------------------------ publisheddate ------------------------------------------*/         private string publisheddate;             public string getpublisheddate() {             return publisheddate;         }          @column(nullable = false)         public void setpublisheddate(string publisheddate) {             this.publisheddate = publisheddate;         }           /*--------------------------------- endtime -----------------------------------*/         private string endtime;                  public string getendtime() {             return endtime;         }         @column(nullable = false)         public void setendtime(string endtime) {             this.endtime = endtime;         }          /*-------------------------------- user ------------------------------------------*/         @manytoone         @joincolumn(name="user_id")            private user user;         public user getuser() {             return user;         }         @column(nullable = false)         public void setuser(user user) {             this.user = user;      } 

then when check jpa diagram, has duplication of several attributes. added jpa diagram image(the red parts duplicated)

enter image description here

this first application java programming. please understand, read documentation of spring jpa, difficult figure out did wrong in code. ideas? in advance.

the problem jpa expects either field level annotations or accessor (getters/setters) annotations. using both, isn't allowed. remove annotations accessors , put them on fields.

small hint on java programming (styling) put fields on top of classes instead of between accessors.

@entity public class event {      @id     @generatedvalue     private integer id;      @column(unique = true)     private string eventid;      private string event_id;      @column(nullable = false)     private string title;      @column(nullable = false)     private string publisheddate;         @column(nullable = false)     private string endtime;               @manytoone     @joincolumn(name="user_id")        @column(nullable = false)     private user user;      // getters / setters omitted  } 

remove annotations accessors, want set id? expect not, might want remove setid method.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -