[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4254?page=c...
]
drekbour commented on HHH-4254:
-------------------------------
Just ran into this one (Hibernate 3.5.3). We are quite surprised this is two years old and
has no visible response. Our 5-minute workaround was to rename our Java field names to
match the annotation:
{noformat}
@Id
@Column("TableID")
private int TableID;
{noformat}
As you can imagine this doesn't sit well with anyone!
@Column annotation ignored when placed on entity's @Id property
---------------------------------------------------------------
Key: HHH-4254
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4254
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Environment: hib core 3.2.6, my sql 5
Reporter: sagi mann
Hibernate docs specify that when using a compound key class, a Hibernate optional feature
is to place @Column annotations within the key class. The observed behavior is that
Hibernate ignores @Column if placed ANYWHERE ELSE, for example, on the entity's ID
properties. In other words, the standard JPA way of annotating ID fields is not working
under Hibernate, and the "optional" feature is mandatory.
Example how to reproduce (see comments inside the code regarding the inconsistency
above). Accessors were omitted for clarity:
// the identity class
@Entity
public class SecurityIdentity implements Serializable {
public SecurityIdentity() {}
@Id
@Column(name="IDENTITY_ID")
@GeneratedValue
public Long getId() ...
@Column(name="IDENTITY_NAME")
public String getName() ...
@Override public boolean equals(Object o) ...
@Override public int hashCode() ...
}
// the domain class
@Entity
public class SecurityDomain implements Serializable {
public SecurityDomain() {}
@Id
@Column(name="DOMAIN_ID")
@GeneratedValue
public Long getId() ...
@Column(name="DOMAIN_NAME")
public String getName() ...
@Override public boolean equals(Object o) ...
@Override public int hashCode() ...
}
// the domain-identity mapping class
@Entity
@IdClass(pu1.DomainIdentityPK.class)
public class DomainIdentity implements Serializable {
public DomainIdentity() {}
@Id
public Long getDomainId() ...
@Id
public String getUserAlias() ...
@ManyToOne
@JoinColumn(name="IDENTITY_ID")
public SecurityIdentity getSecurityIdentity() ...
@ManyToOne
@JoinColumn(name="DOMAIN_ID", insertable=false, updatable=false)
public SecurityDomain getSecurityDomain() { return securityDomain; }
public void setSecurityDomain(SecurityDomain securityDomain) {
this.securityDomain = securityDomain;
this.domainId = (securityDomain != null ? securityDomain.getId() : null);
}
private SecurityDomain securityDomain;
}
// the map key class
public class DomainIdentityPK implements Serializable {
public DomainIdentityPK() {
}
/********* @Column inconsistency - cannot be placed inside the entity - only inside
the PK class *******/
@Column(name="DOMAIN_ID")
public Long getDomainId() ...
[b]@Column(name="ALIAS")[/b]
public String getUserAlias() ...
public boolean equals(Object o) ...
public int hashCode() ...
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira