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

Hrotkó Gábor (JIRA) noreply at atlassian.com
Sun Sep 18 16:36:37 EDT 2011


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


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:

/** 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;
   }
}



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;

}


--
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