]
Dusty commented on EJB-286:
---------------------------
Ok, putting annotations on the idClass worked fine. Thanks
Hibernate does not honor @Column(name=...) annotation with IdClass
------------------------------------------------------------------
Key: EJB-286
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-286
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.1.GA
Environment: Netbeans 5.5, Java6
Reporter: Dusty
I'have an Entity which uses an IdClass, when I execute the simplest query Hibernate
fails because it's using the name of the attribute instead of the one indicated by the
@Column annotation.
The IdClass is defined as follows:
public class DomainAdminId implements Serializable {
private String domainName;
private String adminUser;
public DomainAdminId() {
}
public DomainAdminId(String domainName, String adminUser) {
this.domainName = domainName;
this.adminUser = adminUser;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getAdminUser() {
return adminUser;
}
public void setAdminUser(String adminUser) {
this.adminUser = adminUser;
}
public boolean equals(Object o) {
return ((o instanceof DomainAdminId) &&
domainName.equals(((DomainAdminId)o).getDomainName()) &&
adminUser.equals(((DomainAdminId)o).getAdminUser()));
}
public int hashCode() {
return (domainName+adminUser).hashCode();
}
}
And the following Entity using that idClass:
@Entity
@Table(name="domainadmin")
@IdClass(DomainAdminId.class)
@NamedQueries( {
@NamedQuery(name = "DomainAdmin.test", query = "SELECT d FROM
DomainAdmin d")
)
public class DomainAdmin implements Serializable {
@Id
@Column(name="domain_name")
private String domainName;
@Id
@Column(name="adminuser")
private String adminUser;
public DomainAdmin() {
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getAdminUser() {
return adminUser;
}
public void setAdminUser(String adminUser) {
this.adminUser = adminUser;
}
}
When executing the DomainAdmin.test Named Query I got this error:
could not execute query [select domainadmi0_.adminUser as adminUser1_,
domainadmi0_.domainName as domainName1_ from domainadmin domainadmi0_]
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column
'domainadmi0_.domainName' in 'field list'
In effect, as indicated in the source, the column name is "domain_name" and not
"domainName".
The same apply for the other column: adminUser (that should instead be
"adminuser"),
This issue is blocking for me, do you have any workaround for the time being?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: