2 Replies Latest reply on Jul 1, 2009 3:30 AM by wang wei

    EntityHome update no saved

    wang wei Newbie
      Modify the mcType or mcClass of instance  of module , call moduleHome update(), but the database no changed,also the log not print update SQL.
      Before call update(),I print the value of mcType and mcClass , the value is modified value.

      If modify the mName or mDesc ,call update(), all will be right ,database changed and log print update SQL.
      If modify both moduleClass and mName(mDesc), call update ,all will be right too.
      The moduleClass had @EmbeddedId.
      If moduleClass id is not a @EmbeddedId, meaning the key of ModuleClass not a composite PK ,the PK is mcClass,
      then modify the mcClass of instance of module, call moduleHome update(),database will be changed and pring update SQL in log.
      It is seam bug?
      -------------------
      @Name("moduleHome")
      public class ModuleHome extends EntityHome<Module>{
      ...
      }

      @Entity
      @Table(name="module")
      public class Module implements Serializable{
          private String mId;
          private String mName;
          private String mDesc;
          private ModuleClass moduleClass;
          public Module() {
          }
          @Id
          @Column(name="m_id")
          public String getMId() {
              return mId;
          }
          public void setMId(String mId) {
              this.mId = mId;
          }
         
          @Column(name="m_name")
          public String getMName() {
              return mName;
          }
          public void setMName(String mName) {
              this.mName = mName;
             
          }
         
          @Column(name="m_desc")
          public String getMDesc() {
              return mDesc;
          }
          public void setMDesc(String mDesc) {
              this.mDesc = mDesc;
          }
         
          @ManyToOne
          @JoinColumns({
              @JoinColumn(name="mc_type",referencedColumnName="mc_type")
              ,@JoinColumn(name="mc_class",referencedColumnName="mc_class")})
          public ModuleClass getModuleClass() {
              return moduleClass;
          }
          public void setModuleClass(ModuleClass moduleClass) {
              this.moduleClass = moduleClass;
          }
      ........  
      }

      @Entity
      @Table(name="module_class")
      public class ModuleClass implements Serializable{
          private ModuleClassPK mcPK;
          private String mcName;
          public ModuleClass() {
          }
          @EmbeddedId
          public ModuleClassPK getMcPK() {
              return mcPK;
          }
          public void setMcPK(ModuleClassPK mcPK) {
              this.mcPK = mcPK;
          }
          @Column(name="mc_name")
          public String getMcName() {
              return mcName;
          }
          public void setMcName(String mcName) {
              this.mcName = mcName;
          }
          ......
      }

      @Embeddable
      public class ModuleClassPK implements Serializable {
          private String mcType;
          private String mcClass;
          public ModuleClassPK() {
          }
          @Column(name="mc_type")
          public String getMcType() {
              return mcType;
          }
          public void setMcType(String mcType) {
              this.mcType = mcType;
          }
         
          @Column(name="mc_class")
          public String getMcClass() {
             return mcClass;
          }
          public void setMcClass(String mcClass) {
              this.mcClass = mcClass;
          }
      }