I've been unable to get UpdateOperations.allAll to work in a way that's
consistent with UpdateOperations.add. When I call add, the className attribute
is NOT included with every element of an @Embedded array. However, if I
populate this collection by calling allAll, then every element of the @Embedded
array has the className attribute.
Versions:
Mongo mongodb-linux-x86_64-1.8.2
Morphia 0.99 and 1.00-SNAPSHOT (I tried both)
Repro case runnable:
Datastore ds = getDatastore();
String uuid = "4ec6ada9-081a-424f-bee0-934c0bc4fab7";
Query<EntityLogs> finder =
ds.find(EntityLogs.class).field("uuid").equal(uuid);
// both of these entries will have a className attribute
List<EntityLog> latestLogs = Arrays.asList(new
EntityLog("whatever1"), new EntityLog("whatever2"));
UpdateOperations<EntityLogs> updateOperationsAll =
ds.createUpdateOperations(EntityLogs.class)
.addAll("logs", latestLogs, false);
ds.update(finder, updateOperationsAll, true);
// this entry will NOT have a className attribute
UpdateOperations<EntityLogs> updateOperations3 =
ds.createUpdateOperations(EntityLogs.class)
.add("logs", new EntityLog("whatever3"), false);
ds.update(finder, updateOperations3, true);
// this entry will NOT have a className attribute
UpdateOperations<EntityLogs> updateOperations4 =
ds.createUpdateOperations(EntityLogs.class)
.add("logs", new EntityLog("whatever4"), false);
ds.update(finder, updateOperations4, true);
@Entity(noClassnameStored=true)
public class EntityLogs {
@Id
private ObjectId id;
@Indexed
private String uuid;
@Embedded
private List<EntityLog> logs = new ArrayList<EntityLog>();
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public List<EntityLog> getLogs() {
return logs;
}
public void setLogs(List<EntityLog> logs) {
this.logs = logs;
};
}
@Embedded
public class EntityLog {
private Date receivedTs;
private String value;
public EntityLog() {}
public EntityLog(String value) {
setValue(value);
}
@PrePersist
public void pickReceivedTs() {
setReceivedTs(new Date());
}
public Date getReceivedTs() {
return receivedTs;
}
public void setReceivedTs(Date receivedTs) {
this.receivedTs = receivedTs;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
Original issue reported on code.google.com by jtobe...@gmail.com on 6 Jul 2011 at 2:02
Original issue reported on code.google.com by
jtobe...@gmail.com
on 6 Jul 2011 at 2:02