日期:2014-05-20  浏览次数:20746 次

用hibernate 可以修改 符合主键里的部分字段吗?应该怎么办?
public   class   RepH201   implements   java.io.Serializable   {        

          private   RepH201Id   id;            
         
          private   String   ftableno1;
          private   String   ftableno2;
          private   String   ftableno3;
          private   String   fbuildaddrcode;
          .
          .
          .
          (属性太多省略。。)
}
public   class   RepH201Id     implements   java.io.Serializable   {
          private   String   fmonth;
          private   String   funitcode;
          private   String   fitemname;

          ....get()     set()方法.....

          public   boolean   equals(Object   other)   {
                  if   (   (this   ==   other   )   )   return   true;
  if   (   (other   ==   null   )   )   return   false;
  if   (   !(other   instanceof   RepH201Id)   )   return   false;
  RepH201Id   castOther   =   (   RepH201Id   )   other;  
                 
  return   (   (this.getFmonth()==castOther.getFmonth())   ||   (   this.getFmonth()!=null   &&   castOther.getFmonth()!=null   &&   this.getFmonth().equals(castOther.getFmonth())   )   )
  &&   (   (this.getFunitcode()==castOther.getFunitcode())   ||   (   this.getFunitcode()!=null   &&   castOther.getFunitcode()!=null   &&   this.getFunitcode().equals(castOther.getFunitcode())   )   );
  &&   (   (this.getFitemname()==castOther.getFitemname())   ||   (   this.getFitemname()!=null   &&   castOther.getFitemname()!=null   &&   this.getFitemname().equals(castOther.getFitemname())   )   );
      }
     
      public   int   hashCode()   {
                  int   result   =   17;
                 
                  result   =   37   *   result   +   (   getFmonth()   ==   null   ?   0   :   this.getFmonth().hashCode()   );
                  result   =   37   *   result   +   (   getFunitcode()   ==   null   ?   0   :   this.getFunitcode().hashCode()   )
                  result   =   37   *   result   +   (   getFitemname()   ==   null   ?   0   :   this.getFitemname().hashCode()   );
                  return   result;