私は次のエラーを取得する:playframework JPAエラーとDBの設計上の問題
エラー がJPAエラーが発生したJPA(のEntityManagerFactoryを構築することができません):models.Issue.project上@OneToOneまたは@ManyToOneが未知のエンティティを参照します。 models.Project
ここにあなたが私のエンティティを見ることができます:
package models;
import java.util.*;
import javax.persistence.*;
import play.db.jpa.*;
import models.Issue;
import models.Component;
public class Project extends Model{
public String self;
@Id
public String key;
@OneToMany (mappedBy="Project", cascade=CascadeType.ALL)
public List<Component> components;
@OneToMany (mappedBy="Project", cascade=CascadeType.ALL)
public List<Issue> issues;
public Project(String self, String key) {
this.self = self;
this.key = key;
this.components = new ArrayList<Component>();
this.issues = new ArrayList<Issue>();
}
public Project addComponent(String self, int component_id, String name, int issuecount) {
Component newComponent = new Component(self, component_id, name, issuecount, this);
this.components.add(newComponent);
return this;
}
public Project addIssue(Date created, Date updated, String self, String key,
String type, Status status) {
Issue newIssue = new Issue(created, updated, self, key, type, status, this);
this.issues.add(newIssue);
return this;
}
}
、これは他の
package models;
import java.util.*;
import javax.persistence.*;
import play.db.jpa.*;
import models.Project;
import models.Status;
import models.Component;
@Entity
public class Issue extends Model {
@Id
public String key;
public Date created;
public Date updated;
public String self;
public String type;
@ManyToOne
public Status status;
@ManyToOne
public Project project;
@OneToMany
public List<Component> components;
public Issue(Date created, Date updated, String self, String key,
String type, Status status, Project project) {
this.created = created;
this.updated = updated;
this.self = self;
this.key = key;
this.status = status;
this.type = type;
this.project=project;
this.components=new ArrayList<Component>();
}
public Issue addComponent(Component component) {
this.components.add(component);
return this;
}
}
です
私はPlay 1.2.4とEclipseを使用しています。今私のDBはmemにあります。
私も第2の質問があります。理想的には、各ユーザーにdbが必要です。ユーザーがログイン(またはログアウト)するたびにテーブルの内容を削除し、ユーザーがログインしたときにテーブルを再投入する必要があります(これは、私が接続しているサービスと同期している必要があります)。どうすればいいですか?
私はまったく手掛かりがありません。私を助けてください。
そうです。ごめんなさい。 – GLF
@GLFごめんなさい。これはすべての質問と回答のサイトです。だからあなたはすべてのことを正しく行いましたが、他の誰かがそこから学ぶことができます;-) – dertoni
@GLFこれを正解とマークすることを忘れないでください。 – tmbrggmn