我有一个只提供标识的基类:
public abstract class Identifable<T> {
@Id
private T id = null;
public T getId() {
return id;
}
public void setId(T id) {
this.id = id;
}
public boolean hasId() {
return id != null;
}
}
以及几个扩展它的子类,例如:
@Entity
@Cache
public class MyEntity extends Identifable<String> {
/* some specific attributes and methods */
}
我得到一个java.lang.IllegalStateException: @Id field 'id' in com.mypkg.MyEntity must be of type Long, long, or String
.
为什么?Objectify 看不到继承的@Id
字段吗?谢谢