Reputation: 3793
I try to create a link between two tables : User
and Notifications
The Notifications
tables should have:
I need to clarify my goal. In my app, a user ask something to several others, using notifications tables. So that, we can know:
User
@Entity
public class User extends Model{
@ManyToOne
@JoinColumn(name="notification_fk")
public Notifications notification;
}
Notifications
@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>();
}
But I get the following error:
javax.persistence.PersistenceException: Error on models.Notifications.asked_users Can not find mappedBy property [user] in [models.User]
What did I do wrong?
Upvotes: 0
Views: 1056
Reputation: 55798
In the mappedBy
you need to use the name of the existing oposite field, and it's notification
in your case - without 's' at the end.
Upvotes: 1