I am still getting:
Code:
MySQLSyntaxErrorException: Unknown column 'useridenti0_.identifierId' in 'field list'
I removed the PK class and replace the UserIdentifier class with the attached class,
And refractor all code references from:
UserIdentifier.getUserId()
To
UserIdentifier.getId().getUserId()
Also in the query :
select ui from UserIdentifier ui where ui.id.userId = ?1
instead of
select ui from UserIdentifier ui where ui.userId = ?1
Thank you very much for the code & response,
Sharon
Code:
@Entity
@Table(name = "user_identifier")
public class UserIdentifier implements Serializable {
private Id id;
public UserIdentifier() {
}
@AttributeOverrides(
{
@AttributeOverride(name = "userId", column = @Column(name = "user_id", nullable = false)),
@AttributeOverride(name = "identifierId", column = @Column(name = "identifier_Id", nullable = false)),
@AttributeOverride(name = "value", column = @Column(name = "value", nullable = false))
}
)
@EmbeddedId
public Id getId() {
return this.id;
}
public void setId(final Id id) {
this.id = id;
}
@Embeddable
public static class Id
implements java.io.Serializable {
private long identifierId;
private long userId;
private String value;
public Id() {
}
public Id(final long userId, final long identifierId) {
this.userId = userId;
this.identifierId = identifierId;
}
@Column(name = "user_id", nullable = false)
public long getUserId() {
return this.userId;
}
public void setUserId(final long userId) {
this.userId = userId;
}
@Column(name = "identifier_Id", nullable = false)
public long getIdentifierId() {
return this.identifierId;
}
public void setIdentifierId(final long identifierId) {
this.identifierId = identifierId;
}
@Column(name = "value", nullable = false)
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public boolean equals(final Object other) {
if ((this == other)) {
return true;
}
if ((other == null)) {
return false;
}
if (!(other instanceof Id)) {
return false;
}
final Id castOther = (Id)other;
return (this.getUserId() == castOther.getUserId()) &&
(this.getIdentifierId() == castOther.getIdentifierId() &&
this.getValue().equals(castOther.getValue()));
}
@Override
public int hashCode() {
int result = 17;
result = (37 * result) + (int)this.getUserId();
result = (37 * result) + (int)this.getIdentifierId();
result = (37 * result) + this.getValue().hashCode();
return result;
}
} // end class Id
} // end class TaskOwner