#1457 - Issue with @ManyToOne with @EmbeddedId where only some columns are insertable or updatable

This commit is contained in:
rob bygrave
2018-07-18 21:29:08 +12:00
parent 2d44d06f36
commit 01541bb208
14 changed files with 318 additions and 22 deletions
@@ -0,0 +1,53 @@
package org.tests.model.composite;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.util.Objects;
@Embeddable
public class CkeUserKey {
@Basic(optional = false)
@Column(name = "cod_cpny")
private int codCompany;
@Basic(optional = false)
@Column(name = "username")
private String username;
public CkeUserKey(int codCompany, String username) {
this.codCompany = codCompany;
this.username = username;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CkeUserKey that = (CkeUserKey) o;
return codCompany == that.codCompany &&
Objects.equals(username, that.username);
}
@Override
public int hashCode() {
return Objects.hash(codCompany, username);
}
public int getCodCompany() {
return codCompany;
}
public void setCodCompany(int codCompany) {
this.codCompany = codCompany;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}