2012-01-30 8 views
2

私は次のエラーを取得する: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が必要です。ユーザーがログイン(またはログアウト)するたびにテーブルの内容を削除し、ユーザーがログインしたときにテーブルを再投入する必要があります(これは、私が接続しているサービスと同期している必要があります)。どうすればいいですか?

私はまったく手掛かりがありません。私を助けてください。

答えて

5
public class Project extends Model 

@Entity注釈

+0

そうです。ごめんなさい。 – GLF

+0

@GLFごめんなさい。これはすべての質問と回答のサイトです。だからあなたはすべてのことを正しく行いましたが、他の誰かがそこから学ぶことができます;-) – dertoni

+0

@GLFこれを正解とマークすることを忘れないでください。 – tmbrggmn

4

「mappedBy」は、「プロジェクト」ではなく「プロジェクト」である他のエンティティのプロパティを参照する必要があります。

+0

が完了し行方不明、まだない作品です。 – GLF

関連する問題