I'm trying to make a one-to-one relationship between two tables by using playframework 1.2.5. I would like to create rating list for each user after this mapping. The java code is here:
User.java
@Entity
@Table(name = "`user`")
public class User extends Model {
public String name;
public String surname;
public String password;
public String username;
public Date lastlogin;
}
UserRating.java
@Entity
@Table(name = "`userrating`")
public class UserRating extends Model {
public double rating;
@OneToOne()
@JoinColumn(name="id_user")
public User user;
}
My yaml file is like that. However, I encountered this error: Cannot parse the /conf/initial-data.yml file: mapping values are not allowed here. Could you help to fix this error?
initial-data.yml
- &user19
id: 19
name: freud
surname: lily
password: x56
username: freud
lastlogin: 2010-05-02
- &user20
id: 20
name: osman
surname: özsu
password: 798
username: osman
lastlogin: 2004-12-11
UserRating(1):
rating: 1.2
user:
- *user20
I think the correct syntax would be something like
User(userref):
id: 19
name: freud
surname: lily
password: x56
username: freud
lastlogin: 2010-05-02
# (...)
UserRating:
id: 1
rating: 1.2
user: [userref]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.