GAE JPA嵌入式注释问题

时间:2014-06-11 08:20:40

标签: java google-app-engine jpa datanucleus

好的,我有一个实体学校。

@Entity 
public class School implements Serializable 
{
private static final long serialVersionUID = -854333301529125138L;
@Id 
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ID;  
private String Type;
private String Name;
private String City;
private String Country;

@OneToOne(cascade = CascadeType.PERSIST,fetch=FetchType.LAZY)
private Info information;

@OneToMany(cascade = CascadeType.PERSIST, mappedBy="school",fetch=FetchType.LAZY)
private List<Contact> Contacts;

@OneToMany(cascade = CascadeType.PERSIST, mappedBy="school",fetch=FetchType.LAZY)
private List<Student> students= new ArrayList<Student>();
// more fields and getters and setters.

学生班包含大量学生信息,学生成绩单如下

@Entity
public class Student implements Serializable
{

private static final long serialVersionUID = 5426530769458891752L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key ID;
@ManyToOne 
private School school;
private long SID;
private final long TSTAMP;
private String FName;
private String LName;
private String Email;
private String SchoolName;

@OneToOne(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
private StudentInfo studentInf = new StudentInfo ();
@OneToOne(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
private Transcript transcript;
 // more fields and getters and setters.

学生班的成绩单类如下

@Entity
public class Transcript
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key ID;
@OneToOne(cascade = CascadeType.ALL, mappedBy="transcript",fetch=FetchType.LAZY)
private Student student;
@Embedded 
private Course1 c1;
@Embedded 
private Course2 c2;
@Embedded 
private Course3 c3;
//... ect
public Transcript()
{
    this.c1= new Course1();
    this.c2= new Course2();
    this.c3= new Course3();
    // ... ect
}

// more fields and getters and setters.

最后这是一个示例课程

@Embeddable
public class Course1 implements Serializable
{
/**
 * 
 */
private static final long serialVersionUID = -7643055124732162110L;

private final String CourseTitle = "Course 1 Title";
private boolean MileStone1 = false;
private boolean MileStone2 = false;
// ... ect ... getters and setters
}

所有类在没有问题的情况下进行增强并且服务器运行,但是一旦创建了学生实例,就会在GAE开发服务器中导致完全灾难,并且我尝试了很多可能的选项并使用相同的错误消息:< / p>

"java.lang.IllegalArgumentException: org.datanucleus.exceptions.NucleusUserException: You have a field db.Entity.student.Student.transcript that has type db.Entity.Courses.Transcript but this type has no known metadata. Your mapping is incorrect"

我非常感谢您解释为什么会发生这种情况以及如何在保持逻辑关系的同时解决问题

0 个答案:

没有答案