I am currently developing a little Group Management System and using java 8 with eclipselink and SqlLite.
@Entity
@Table(name = "T_GROUP")
public class Group {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private List<Permission> permissions;
private boolean defaultGroup;
private String prefix;
private String suffix;
private int rank;
private boolean build;
@OneToOne
private Group inherit;
/**
* Instantiates a new Group.
*/
public Group() {
}
...Getters Setters
}
The Field inherit references to another group that has other permissions, but the current group inherits all permissions from the other group. How do I work with the field inherit? It is the same Type. The OneToOne relation gives me following error:
Internal Exception: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "CONSTRAINT": syntax error)
Error Code: 0
Call: ALTER TABLE T_GROUP ADD CONSTRAINT FK_T_GROUP_INHERIT_ID FOREIGN KEY (INHERIT_ID) REFERENCES T_GROUP (ID)