https://blog.csdn.net/wyc_cs/article/details/9031991

创建一个复合主键类

public class LevelPostMultiKeysClass  implements Serializable{
private Integer levelId;
private Integer postId; public LevelPostMultiKeysClass() {
} public LevelPostMultiKeysClass(Integer levelId, Integer postId) {
this.levelId = levelId;
this.postId = postId;
} @Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((levelId == null) ? 0 : levelId.hashCode());
result = PRIME * result + ((postId == null) ? 0 : postId.hashCode());
return result;
} @Override
public boolean equals(Object obj){
if(this == obj){
return true;
}
if(obj == null){
return false;
}
if(getClass() != obj.getClass()){
return false;
} final LevelPostMultiKeysClass other = (LevelPostMultiKeysClass)obj;
if(levelId == null){
if(other.levelId != null){
return false;
}
}else if(!levelId.equals(other.levelId)){
return false;
}
if(postId == null){
if(other.postId != null){
return false;
}
}else if(!postId.equals(other.postId)){
return false;
}
return true;
} }

springboot jpa  复合主键-LMLPHP

springboot jpa  复合主键-LMLPHP

springboot jpa  复合主键-LMLPHP


05-11 13:12