[hibernate-issues] [Hibernate-JIRA] Updated: (METAGEN-76) SingularAttribute generated for hashCode method in @Embeddable

Hardy Ferentschik (JIRA) noreply at atlassian.com
Wed Jan 18 03:28:10 EST 2012


     [ http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-76?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hardy Ferentschik updated METAGEN-76:
-------------------------------------

    Description: 
I got a class composite id class for a table with @Embeddable.
It has two properties, and the equals and the hashCode methods.
When hibernate-jpamodelgen 1.1.1.Final generates the metaclasses, I got a SingularAttribute with the name "hashCode" generated. But hashCode is not a property in the entity.


entity:
{code}
/** by hbm2java */
@Embeddable
public class MyTableId  implements java.io.Serializable {

    private String id;
    private Integer memberId;

    public MyTableId() {
    }

    public MyTableId(String id, Integer memberId) {
       this.id = id;
       this.memberId = memberId;
    }

    @Column(name="id")
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }

    @Column(name="member_id")
    public Integer getMemberId() {
        return this.memberId;
    }
    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

   public boolean equals(Object other) {
         if ( (this == other ) ) return true;
         if ( (other == null ) ) return false;
         if ( !(other instanceof MyTableId) ) return false;
         MyTableId castOther = ( MyTableId ) other;

         return ( (this.getId()==castOther.getId()) || ( this.getId()!=null && castOther.getId()!=null && this.getId().equals(castOther.getId()) ) )
 && ( (this.getMemberId()==castOther.getMemberId()) || ( this.getMemberId()!=null && castOther.getMemberId()!=null && this.getMemberId().equals(castOther.get
MemberId()) ) );
   }

   public int hashCode() {
         int result = 17;

         result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
         result = 37 * result + ( getMemberId() == null ? 0 : this.getMemberId().hashCode() );
         return result;
   }
}
{code}


metaclass:
{code}
@StaticMetamodel(MyTableId.class)
public abstract class MyTableId_ {
   public static volatile SingularAttribute<MyTableId, String> id;
   public static volatile SingularAttribute<MyTableId, Integer> hashCode;
   public static volatile SingularAttribute<MyTableId, Integer> memberId;
}
{code}


  was:
I got a class composite id class for a table with @Embeddable.
It has two properties, and the equals and the hashCode methods.
When hibernate-jpamodelgen 1.1.1.Final generates the metaclasses, I got a SingularAttribute with the name "hashCode" generated. But hashCode is not a property in the entity.


entity:
{code}
/** by hbm2java */
@Embeddable
public class MyTableId  implements java.io.Serializable {

    private String id;
    private Integer memberId;

    public MyTableId() {
    }

    public MyTableId(String id, Integer memberId) {
       this.id = id;
       this.memberId = memberId;
    }

    @Column(name="id")
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }

    @Column(name="member_id")
    public Integer getMemberId() {
        return this.memberId;
    }
    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

   public boolean equals(Object other) {
         if ( (this == other ) ) return true;
         if ( (other == null ) ) return false;
         if ( !(other instanceof MyTableId) ) return false;
         MyTableId castOther = ( MyTableId ) other;

         return ( (this.getId()==castOther.getId()) || ( this.getId()!=null && castOther.getId()!=null && this.getId().equals(castOther.getId()) ) )
 && ( (this.getMemberId()==castOther.getMemberId()) || ( this.getMemberId()!=null && castOther.getMemberId()!=null && this.getMemberId().equals(castOther.get
MemberId()) ) );
   }

   public int hashCode() {
         int result = 17;

         result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
         result = 37 * result + ( getMemberId() == null ? 0 : this.getMemberId().hashCode() );
         return result;
   }
}
{code}


metaclass:

@StaticMetamodel(MyTableId.class)
public abstract class MyTableId_ {

        public static volatile SingularAttribute<MyTableId, String> id;
        public static volatile SingularAttribute<MyTableId, Integer> hashCode;
        public static volatile SingularAttribute<MyTableId, Integer> memberId;

}



> SingularAttribute generated for hashCode method in @Embeddable
> --------------------------------------------------------------
>
>                 Key: METAGEN-76
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-76
>             Project: Hibernate Metamodel Generator
>          Issue Type: Bug
>          Components: processor
>    Affects Versions: 1.1.1.Final
>         Environment: hibernate-jpamodelgen 1.1.1.Final, postgresql 8
>            Reporter: Hrotkó Gábor
>            Assignee: Hardy Ferentschik
>              Labels: metamodel
>             Fix For: 1.x
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> I got a class composite id class for a table with @Embeddable.
> It has two properties, and the equals and the hashCode methods.
> When hibernate-jpamodelgen 1.1.1.Final generates the metaclasses, I got a SingularAttribute with the name "hashCode" generated. But hashCode is not a property in the entity.
> entity:
> {code}
> /** by hbm2java */
> @Embeddable
> public class MyTableId  implements java.io.Serializable {
>     private String id;
>     private Integer memberId;
>     public MyTableId() {
>     }
>     public MyTableId(String id, Integer memberId) {
>        this.id = id;
>        this.memberId = memberId;
>     }
>     @Column(name="id")
>     public String getId() {
>         return this.id;
>     }
>     public void setId(String id) {
>         this.id = id;
>     }
>     @Column(name="member_id")
>     public Integer getMemberId() {
>         return this.memberId;
>     }
>     public void setMemberId(Integer memberId) {
>         this.memberId = memberId;
>     }
>    public boolean equals(Object other) {
>          if ( (this == other ) ) return true;
>          if ( (other == null ) ) return false;
>          if ( !(other instanceof MyTableId) ) return false;
>          MyTableId castOther = ( MyTableId ) other;
>          return ( (this.getId()==castOther.getId()) || ( this.getId()!=null && castOther.getId()!=null && this.getId().equals(castOther.getId()) ) )
>  && ( (this.getMemberId()==castOther.getMemberId()) || ( this.getMemberId()!=null && castOther.getMemberId()!=null && this.getMemberId().equals(castOther.get
> MemberId()) ) );
>    }
>    public int hashCode() {
>          int result = 17;
>          result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
>          result = 37 * result + ( getMemberId() == null ? 0 : this.getMemberId().hashCode() );
>          return result;
>    }
> }
> {code}
> metaclass:
> {code}
> @StaticMetamodel(MyTableId.class)
> public abstract class MyTableId_ {
>    public static volatile SingularAttribute<MyTableId, String> id;
>    public static volatile SingularAttribute<MyTableId, Integer> hashCode;
>    public static volatile SingularAttribute<MyTableId, Integer> memberId;
> }
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list