In this scenario a Lobby can has many Indicators. I tried to make a bidirectional relation without good results. See the Lobby class:
@Entity
@Table(name="lobbies")
public class Lobby {
@Id
@Column(name="id_lobby")
protected int id;
@OneToMany(cascade=CascadeType.ALL)
@JoinColumn(name="lobby", referencedColumnName="id_lobby")
private List<Indicator> indicators;
lobbies table:
+----------+-----------------+
| id_lobby | name |
+----------+-----------------+
| 1 | interna-lobby-1 |
+----------+-----------------+
The Indicator class:
@Entity
@Table(name="indicators")
public class Indicator{
@Id
@Column(name="id_indicator")
private int id;
@ManyToOne
private Lobby lobby;
indicators tables:
+--------------+-------+
| id_indicator | lobby |
+--------------+-------+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
+--------------+-------+
Running the application prints this error:
javax.persistence.PersistenceException: Error with [com.monkey.models.Indicator] I believe it is not enhanced but it's superClass [class java.lang.Object] is? (You are not allowed to mix enhancement in a single inheritance hierarchy)
If I remove lobby attribute from Indicator class, the application runs without problem, but I lose a reference to Lobby from Indicator. What am I missing?
Not sure if is necessary this mention, but I am using this framework based in JPA: http://ebean-orm.github.io/docs/mapping/