I'm working on a program to organize my boredom. I started recently so I haven't began on the GUI yet. The program was working fine with videos/book but now that I added Game
I get a queryException
. Does someone know what I did wrong?
The error:
Caused by: Exception [EclipseLink-6029] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException Exception Description: A reference class must be provided.
The line where the error takes place:
public <E> List<E> getAll(Class<E> eClass){return manager.createQuery(manager.getCriteriaBuilder().createQuery(eClass)).getResultList(); }
Where the line gets called for the different entity types
for (Class eClass: Project.getAllItemTypes())
repos.put(eClass, new Repository(persistenceAdministrator, eClass));
The Entity types
public static Class[] getAllItemTypes(){
return new Class[]{Movie.class, TvShow.class, ComedyShow.class, Book.class, Comicbook.class, Manga.class, Game.class};
}
The create-sql for Game
and Task
CREATE TABLE Game(
id INT NOT NULL AUTO_INCREMENT,
stateStr VARCHAR(50) NOT NULL,
title VARCHAR(100) NOT NULL,
releaseDate DATE NOT NULL,
gameId INT NULL,
PRIMARY KEY (id),
CONSTRAINT FK_gameId_game
FOREIGN KEY (gameId)
REFERENCES Game (id));
CREATE TABLE Task(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
completed BOOLEAN NOT NULL,
gameId INT NOT NULL,
PRIMARY KEY (id),
CONSTRAINT FK_gameId_task
FOREIGN KEY (gameId)
REFERENCES Game (id));
Game Class:
@Entity
public class Game extends Item implements Serializable{
@OneToMany
private List<Game> children = new ArrayList<>();
@OneToMany
private List<Task> tasks = new ArrayList<>();
}
Item class
@MappedSuperclass
public abstract class Item extends IEntity implements Serializable{
@Transient
private State state;
@Column(nullable=false)
private String stateStr;
@Basic(optional = false)
@Column(name = "releaseDate")
@Temporal(TemporalType.DATE)
private Calendar releaseDate;
@Column(nullable=false)
private String title;
IEntity class
@MappedSuperclass
public abstract class IEntity extends Object implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;