I'm new to Ebean's world, and I encounter some difficulties to set some relationships between entities.
I have basically two classes, User
and Car
.
A user can have several cars (so I guess OneToMany
) and a car can belongs to one User (so I guess OneToOne
).
How can I link these two entities? Here it is what I've done so far
User
@Entity
public class User extends Model{
@Id
@GeneratedValue
public int id;
public String name;
@ManyToMany(cascade=CascadeType.ALL)
public List<Car> car = new ArrayList<Car>();
}
Car
@Entity
public class Car extends Model{
@Id
@GeneratedValue
public int id;
@OneToOne(cascade = CascadeType.ALL)
public User user;
}
And I get the following error
PersistenceException: Error on models.User.car Can not find mappedBy property [users] in [models.Car]
Can someone explain me clearly how to use annotations the correct way (very poor documentation), and tell me why I get this error?