Ich habe folgende Comment
Einheit:Frühling JPA ändert Einheit boolean Variablennamen, wenn Rückkehr Entitätsobjekt
@Entity
@Table(name = "comment")
public class Comment extends AbstractEntity
Und einer der Säule:
@Column(name = "is_deleted")
private Boolean isDeleted;
Das zurücke Kommentar Objekt ändert die Variablennamen aus isDeleted
zu gelöscht.
Und wenn ich das Objekt Comment
von Client-Aufruf speichern. Wenn ich sage isDeleted: false, Und was ich bekomme, ist gelöscht: null. Und wenn ich deleted: false sage, was ich bekomme, wird gelöscht: false. Es sieht so aus, als wäre der Spaltenname gelöscht, aber nicht isDeleted.
Ich weiß nicht, warum das passiert.
Die gesamte Kommentar Einheit Code:
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 +
'}';
}
}
Was meinen Sie mit: "Das zurückgegebene Kommentarobjekt ändert den Namen der Variablen isDeleted in deleted" ?? – pleft
Es sollte zurückgeben: isDeleted: true/false. Aber was ich bekomme ist gelöscht: null/true/false. –
Haben Sie Getter/Setter-Methoden für die Eigenschaft 'isDeleted'? Kannst du sie auch posten? In der Tat posten Sie die gesamte "Kommentar" -Klasse. Meiner Meinung nach sollte die Eigenschaft 'isDeleted' in Ihrer Klasse in' deleted' umbenannt werden. – pleft