Я получаю следующую ошибку:
Ошибка JPA
Произошла ошибка JPA (невозможно построить EntityManagerFactory): @OneToOne или @ManyToOne на моделях. Isue.project ссылается на неизвестную сущность: 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. Теперь моя БД в памяти.
У меня также есть второй вопрос. В идеале мне нужна база данных для каждого пользователя, и я хочу удалять содержимое таблиц каждый раз, когда пользователь входит (или выходит), и снова заполнять таблицу, когда пользователь входит в систему (это потому, что информация, хранящаяся в моей базе данных, должна быть в синхронизации с сервисом, к которому я подключаюсь). Как мне быть?
Я совершенно не понимаю. Пожалуйста, помогите мне.