I以下Comment
エンティティがあります。春のJPAエンティティブール変数名を変更したときのリターンエンティティオブジェクト
@Entity
@Table(name = "comment")
public class Comment extends AbstractEntity
と列の1:
@Column(name = "is_deleted")
private Boolean isDeleted;
返されたコメントオブジェクトはから変数名を変更しますisDeleted
を削除してください。
クライアントコールからComment
オブジェクトを保存したとき。私が言うならisDeleted:false、そして私が得るものは削除されます:null。私が削除と言う場合:false、私が得るものは削除されます:false。カラム名は削除されますが、isDeletedはそうではありません。
これがなぜ起こるのかわかりません。
全体コメントエンティティコード:
package no.nsd.archivingportal.domain.comment;
import no.nsd.archivingportal.domain.AbstractEntity;
import no.nsd.archivingportal.domain.user.User;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.UUID;
@Entity
@Table(name = "comment")
public class Comment extends AbstractEntity {
@Type(type="pg-uuid")
@Column(name = "commented_entity")
private UUID commentedEntity;
@ManyToOne
@JoinColumn(name = "user_id")
private User author;
@Column(name = "content")
private String content;
@Column(name = "is_deleted")
private Boolean isDeleted;
public UUID getCommentedEntity() {
return commentedEntity;
}
public void setCommentedEntity(UUID commentedEntity) {
this.commentedEntity = commentedEntity;
}
public User getAuthor() {
return author;
}
public void setAuthor(User author) {
this.author = author;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Boolean getDeleted() {
return isDeleted;
}
public void setDeleted(Boolean deleted) {
isDeleted = deleted;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Comment comment = (Comment) o;
if (commentedEntity != null ? !commentedEntity.equals(comment.commentedEntity) : comment.commentedEntity != null)
return false;
if (author != null ? !author.equals(comment.author) : comment.author != null) return false;
if (content != null ? !content.equals(comment.content) : comment.content != null) return false;
return isDeleted != null ? isDeleted.equals(comment.isDeleted) : comment.isDeleted == null;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (commentedEntity != null ? commentedEntity.hashCode() : 0);
result = 31 * result + (content != null ? content.hashCode() : 0);
result = 31 * result + (isDeleted != null ? isDeleted.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Comment{" +
"commentedEntity=" + commentedEntity +
", author=" + author +
", content='" + content + '\'' +
", isDeleted=" + isDeleted +
'}';
}
}
「返されたコメントオブジェクトは、isDeleted変数名を削除する」とはどういう意味ですか? – pleft
戻り値:isDeleted:true/false。 しかし、私が得るものは削除されます:null/true/false。 –
'isDeleted'プロパティのgetter/setterメソッドがありますか?あなたもそれらを投稿できますか?実際に 'Comment'クラス全体を投稿します。私の意見では、クラス内で 'isDeleted'プロパティの名前を' deleted'に変更する必要があります。 – pleft