0 Replies Latest reply on Mar 6, 2006 8:56 PM by song hao

    @JoinColumn problem

    song hao Newbie

      Hi, all
      I have a problem about @JoinColumn.

      Status.java

      @Entity
      public class Status implements Serializable {
       @Id
       private String Status_ID;
      
       private String Status_Msg;
      
       public String getStatus_ID() {
       return Status_ID;
       }
      
       public void setStatus_ID(String status_id) {
       Status_ID = status_id;
       }
      
       public String getStatus_Msg() {
       return Status_Msg;
       }
      
       public void setStatus_Msg(String status_msg) {
       Status_Msg = status_msg;
       }
      }


      Table Status:
      Status_ID Status_Msg
      ----------- --------------
       O Open
       C Close
       F Fatal


      Table Status have three lines data, unallowed insert other data.

      Light.java
      @Entity
      public class Light implements Serializable {
       @Id
       private String Light_Name;
      
       @ManyToOne
       @JoinColumn(name = "Light_Status", referencedColumnName="Status_ID")
       private Status LightStatus;
      
       public String getLight_Name() {
       return Light_Name;
       }
      
       public void setLight_Name(String light_name) {
       Light_Name = light_name;
       }
      
       public Status getLightStatus() {
       return LightStatus;
       }
      
       public void setLightStatus(Status lightstatus) {
       LightStatus = lightstatus;
       }
      }


      Table Light
      Light_Name Light_Status
      -------------- --------------
      light1 O
      light2 O
      light3 C
      light4 F


      Table Light Column Light_Status, auto create in @JoinColumn, not have setter/getter. How to do when i want to chang "light2" to Close(change Light_Status to "C").

      another question:

      Table Desk:
      Desk_Zone Desk_ID
      ------------- -----------
       A 01
       B 09

      Table ChkAllo
      Desk_Code
      -------------
       A01
       B09


      How to create the OneToOne relationship about Desk.Desk_Zone + Desk.Desk_ID = ChkAllo.Desk_Code?