Using Objectify 4, name and price fields are not persisted when I save a MenuItem object.
Only Key, WriteOps and ID/Name are persisted in the debugging datastore.
@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;
}
}
Where BaseEntity is:
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);
}
}
and Dto is:
public interface Dto extends Serializable {
}
Any ideas? Thanks!
As stated on the Objectify mailing list, it may just be your viewing of the datastore that is missing this information.
Can you show some test code to save this data then retrieve it and print out the results rather than using the datastore viewer? I’d expect: