I am using the google datastore with objectify 4.0.1 to store messages. Each message has a list of Comments attached.
Message id 5708313257836544 has 16 comments. At 10:34:08 a 17th comment is added. A GET at 12:01:46 shows the message has 17 comments, another at 12:02 shows it has 16, and the following at 12:04 returns 17 again. No comments have been deleted.
The code is as follows:
@Entity
public class Message {
@Id private Long id;
private List<Comment> comments;
//getters and setters
//equals and hashcode over-ridden using id
}
@Embed
public class Comment {
private String message;
private Date date;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Date getDate() {
return date;
}
public int hashCode() {
return date.hashCode() * message.hashCode();
}
public boolean equals(Object obj) {
if (obj==this)
return true;
if ( !(obj instanceof Comment) )
return false;
Comment other = (Comment) obj;
return other.getMessage().equals(message) && other.getDate().equals(date);
}
I've not enabled caching for these objects with the @Cache annotation.
Why might this inconsistency be happening, and how do I prevent it?