【发布时间】:2015-03-30 07:07:54
【问题描述】:
我尝试在两个表之间创建链接:User 和 Notifications Notifications 表应该有:
- ID(整数)
- User_Id (int)
- 列表
我需要澄清我的目标。在我的应用程序中,用户使用通知表向其他几个人询问一些事情。因此,我们可以知道:
- 提问的用户是谁 (User_Id)
- 向谁提出问题(列表)
用户
@Entity
public class User extends Model{
@ManyToOne
@JoinColumn(name="notification_fk")
public Notifications notification;
}
通知
@Entity
public class Notifications extends Model{
@Id
@GeneratedValue
public int id;
public User user;
@OneToMany(cascade=CascadeType.ALL, mappedBy="notifications")
public List<User> asked_users = new ArrayList<User>();
}
但我收到以下错误:
javax.persistence.PersistenceException:错误 models.Notifications.asked_users 找不到 mappedBy 属性 [models.User]中的[user]
我做错了什么?
【问题讨论】:
标签: mysql orm playframework-2.0 ebean playframework-2.3