У меня есть следующий комментарий < /code> entity: < /p>
@Entity
@Table(name = "comment")
public class Comment extends AbstractEntity
< /code>
и один из столбцов: < /p>
@Column(name = "is_deleted")
private Boolean isDeleted;
< /code>
Возвращенный объект комментария изменяет имя переменной из iSdeled < /code> на удаление. Если я скажу Isdeleted: Неверно, и то, что я получаю, удалено: null. И если я скажу удалить: ложь, то, что я получаю, удалено: ложь. Так выглядит так, как будто имя столбца удаляется, но не сделия. < /P>
Не знаю, почему это происходит.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 +
'}';
}
}
Подробнее здесь: https://stackoverflow.com/questions/398 ... ity-object
Spring JPA изменяет логическое имя объекта, когда объект возврата объекта объекта ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
PHP не изменяет первую строку после заголовка в файле CSV, но изменяет последующие строки
Anonymous » » в форуме Php - 0 Ответы
- 34 Просмотры
-
Последнее сообщение Anonymous
-
-
-
PHP не изменяет первую строку после заголовка в файле CSV, но изменяет последующие строки
Anonymous » » в форуме Php - 0 Ответы
- 25 Просмотры
-
Последнее сообщение Anonymous
-