Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

playframework JPA Error and DB design issue

I get the following error:

JPA error A JPA error occurred (Unable to build EntityManagerFactory): @OneToOne or @ManyToOne on models.Issue.project references an unknown entity: models.Project

Here you can see my entities:

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;
    }


}

and this is the other

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;
}



}

I'm using Play 1.2.4 and Eclipse. Now my db is in mem.

I have also a second question. Ideally I need a db for each user and I want to delete the content of the tables every time the user logs in ( or logs out ) and populate the table again when the user logs in (this is because the information stored in my db must be in synch with service I'm connecting to ). How should I do?

I totally have no clue. Please help me.

like image 699
GLF Avatar asked Mar 02 '26 20:03

GLF


1 Answers

public class Project extends Model

is missing the @Entity annotation

like image 155
Terrell Plotzki Avatar answered Mar 04 '26 13:03

Terrell Plotzki