i try to create composite primary key in table from 2 foreign key using hibernate JPA,but gives me error.I find some solution on net but nothing
The relations betw
Remove constructor from
@EmbeddedId
private ServiceDepartmentPK serviceDepartmentPK;
Remove @ManyToOne annotation from ServiceDepartmentPK class and set fields types to long or int
@Embeddable
public class ServiceDepartmentPK implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="COLUMN_NAME")
private long clientId;
@Column(name="COLUMN_NAME")
private long carServiceId;
public ServiceDepartmentPK () {
}
// getters setters for client and carserver ids-s
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ServiceDepartmentPK )) {
return false;
}
ServiceDepartmentPK castOther = (ServiceDepartmentPK )other;
return
(this.scopeId == castOther.clientId)
&& (this.scriptId == castOther.carServiceId);
}
public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + ((int) (this.clientId ^ (this.clientId>>> 32)));
hash = hash * prime + ((int) (this.carServiceId ^ (this.carServiceId>>> 32)));
return hash;
}
}