0
Objectify 4를 사용하면 MenuItem 개체를 저장할 때 이름과 가격 필드가 유지되지 않습니다. 키, WriteOps 및 ID/이름 만 디버깅 데이터 저장소에 유지됩니다.Objectify 4 - 필드가 유지되지 않습니다.
public abstract class BaseEntity implements Dto {
private static final long serialVersionUID = 8400346403708831769L;
@Id
protected Long id;
protected BaseEntity() {
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.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;
}
BaseEntity other = (BaseEntity) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
public Long getId() {
return id;
}
public void setId(@Nullable Long id) {
this.id = id;
}
public boolean isSaved() {
return (id != null);
}
}
와 DTO는 다음과 같습니다 :
public interface Dto extends Serializable {
}
어떤 아이디어 BaseEntity는
@Entity
public class MenuItem extends BaseEntity {
private String name;
private double price;
public MenuItem() {
}
public MenuItem(String name, double price) {
this.name = name;
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
? 감사!
고마워! 내 필드가 실제로 유지되었지만 필드에 @Index 주석이 없기 때문에 데이터 저장소 뷰어에 표시되지 않는 것을 알 수있었습니다. – spg