java – play framework Exception – field .. No default value
•
Java
Running my play framework applet, I get the following exception:
Error play spit out in browser
I have 2 physical mail and users
1)Mail. java
@Entity public class Mail extends Model { public String title; public Date sentAt; @OneToMany public List<User> sentTO; @OneToMany public List<User> sentBCC; public String content; @ManyToOne public User author; //more code ... }
2)User. java
@Entity public class User extends Model { public String email; public String password; public String fullname; public boolean isAdmin; @OneToMany(mappedBy="author",cascade= CascadeType.ALL) public List<Mail> mails ; public User(String email,String password,String fullname) { this.email = email; this.password = password; this.fullname = fullname; } }
Full stack
I have been groping for this mistake for some time, but I can't solve it Can someone help me understand why I received this error?
Solution
First, SendTo and sendbcc should be mapped to @ manytomany
Secondly, by default, join tables are used to implement non directed @ onetomany mappings and all @ manytomany mappings, and the default generation policy of join table names does not allow you to have multiple such relationships between the same classes
You need to specify the connection table name explicitly:
@ManyToMany @JoinTable(name = "User_Mail_To") public List<User> sentTO; @ManyToMany @JoinTable(name = "User_Mail_Bcc") public List<User> sentBCC;
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码