我想從我的數據存儲使用objectify刪除一個實體,但似乎並沒有被刪除,即使關閉實例並重新啓動它。這是實體看起來像在數據存儲中的內容(既當它是生產服務器&開發服務器上):Objectify刪除似乎沒有工作
這是我使用的嘗試,並刪除它的代碼:
@ApiMethod(name = "deleteDataVersion")
public Result deleteDataVersion(@Named("id") String id) {
// Where id is the id of the entity in the datastore.
if (id != null && !id.equals("")) {
ofy().delete().type(DataVersion.class).id(id).now();
return new Result(Result.STATUS_SUCCESS);
} else
return new Result(Result.STATUS_FAILED);
}
我也試過這樣的代碼:
@ApiMethod(name = "deleteDataVersion")
public Result deleteDataVersion(@Named("id") String id) {
if (id != null && !id.equals("")) {
// DataVersion doesn't have a parent.
Key<DataVersion> key = Key.create(null, DataVersion.class, id);
ofy().delete().key(key).now();
return new Result(Result.STATUS_SUCCESS);
} else
return new Result(Result.STATUS_FAILED);
}
但實體永遠不會被刪除。這是我的實體代碼:
@Entity
public class DataVersion {
@Id
private Long id;
String folderName;
@Index
String effective;
public DataVersion() {
}
public DataVersion(String folderName, String effective) {
this.folderName= folderName;
this.effective = effective;
}
// Getters & setters..
}
我似乎無法找到問題:(任何幫助將不勝感激我敢肯定這件事情未成年我俯瞰(相當新的客體/ AppEngine上)。
id可以是String或Long,但「請注意,數字ID和字符串ID不等效; 123和」123「是不同的ID。 – SpyZip