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  复合主键

 

springboot jpa  复合主键

springboot jpa  复合主键

 

 

 

 




相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-06-15
  • 2021-10-06
  • 2021-08-23
相关资源
相似解决方案