0
我升級了我的應用程序以使用Objectify4,但我無法讓訂單正常工作。 這是我做的: 我有一個類我想查詢的優惠。這個類從Mail和Model擴展而來。訂單的屬性應該是在Mail-Class中索引的日期時間。Objectify4訂單?
import com.googlecode.objectify.annotation.EntitySubclass;
import com.googlecode.objectify.annotation.Serialize;
@EntitySubclass(index=true)
public class Offer extends Mail {
private static final long serialVersionUID = -6210617753276086669L;
@Serialize private Article debit;
@Serialize private Article credit;
private boolean accepted;
...
}
import com.googlecode.objectify.annotation.EntitySubclass;
import com.googlecode.objectify.annotation.Index;
@EntitySubclass(index=true)
public class Mail extends Model {
private static final long serialVersionUID = 8417328804276215057L;
@Index private Long datetime;
@Index private String sender;
@Index private String receiver;
...}
import java.io.Serializable;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Index;
@Entity
public class Model implements Serializable {
private static final long serialVersionUID = -5821221296324663253L;
@Id Long id;
@Index String name;
@Ignore transient private Model parent;
@Ignore transient private boolean changed;
...}
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
public class DatabaseService {
static {
ObjectifyService.register(Model.class);
ObjectifyService.register(Mail.class);
ObjectifyService.register(Offer.class);
}
public static Objectify get() {
return ObjectifyService.ofy();
}
}
,這就是我想做的事:
Query<Offer> result = DatabaseService.get().load().type(Offer.class).order("-datetime");
Unfortunely,結果總是不排序。
有沒有人提示?
鏈接:https://code.google.com/p/objectify-appengine/wiki/Entities#Polymorphism – konqi