我试图在 GAE DB 中存储一个类,它的一些字段本身就是类。就在进入更多细节之前,我想说在我添加这些新的类字段之前它工作得很好。所以,我按照这里的文档:https ://developers.google.com/appengine/docs/java/datastore/jdo/dataclasses 我收到了这个错误:
org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "The class "sportteam.web.client.User" is not persistable. 这意味着它要么没有被增强,要么文件的增强版本不在 CLASSPATH 中(或被未增强的版本隐藏),或找不到该类的元数据/注释。” 是不可持久的。这意味着它要么没有被增强,要么文件的增强版本不在 CLASSPATH 中(或被未增强的版本隐藏),或者找不到该类的元数据。
我尝试使用的主要类是用户:
@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class User implements Serializable
{
// data members
// user unique facebook id
@Persistent
@PrimaryKey
private String facebook_id;
// users facebook code
@Persistent
private String facebook_code;
// users device ID code
@Persistent
private String dev_id;
// users registration ID code
@Persistent
private String reg_id;
// user first name
@Persistent
private String first_name;
// user last name
@Persistent
private String last_name;
// user age, should be grater then 8
@Persistent
private int age;
// user email, as setup in facebook
@Persistent
private String email;
// user weight, should be greater then 40
@Persistent
private double weight;
// user workout_level (0.8 is the highest(best shape) and 1 is the lowest)
@Persistent
private double workout_level;
// user gender ("male"/"female"/"unknown")
@Persistent
private String gender;
@Persistent
@Embedded
private UserTracks userTracks = null;
// default constructor
public User()
{
}
//....
}
这是 UserTracks 类:
@PersistenceCapable
@EmbeddedOnly
@SuppressWarnings("serial")
public class UserTracks implements Serializable
{
@Persistent
@Embedded
//@Element(embedded="true")
private List<Track> tracks = null;
@Persistent
private long date = 0;
public UserTracks()
{
}
}
这些是使用的其他 2 个类:
@PersistenceCapable
@EmbeddedOnly
@SuppressWarnings("serial")
public class Track implements Serializable
{
/** running information **/
@Persistent
private double avgSpeed = 0;
@Persistent
private double distance = 0;
@Persistent
private double calories = 0;
@Persistent
private long time = 0;
/************************/
@Persistent
private long date = 0;
@Persistent
private String name = null;
@Persistent
@Embedded
private List<GeoPtr> track = null;
public Track()
{ // needed for Serializable
}
}
地理坐标:
@PersistenceCapable
@EmbeddedOnly
@SuppressWarnings("serial")
public class GeoPtr implements Serializable
{
/** the speed is in m/s **/
@Persistent
float speed;
@Persistent
long time;
@Persistent
double altitude;
@Persistent
double latitude;
@Persistent
double longitude;
@Persistent
double calorie = 0;
public GeoPtr()
{ //needed for Serializable
}
}
据我所见,每个类都是 PersistenceCapable 并且所有字段都是 PersistenceCapable 本身或它的集合,根据上面的文档,它应该可以工作。
想法?
谢谢