我必须根据我的应用需求定义4个模型 Real_User,Tourism_Questions_Table,Tourism_User_Questions表和 Tourism_Answers_Table。我必须绘制他们无法绘制的地图 弥补 首先,我有一个Real_User模型 创建并填充了一些数据,并且效果很好
@Entity( name = Real_User)
public class RealUser {
@Id
@Column(name = "Email")
private String email;
@Column(name = "FirstName")
private String firstName;
@Column(name = "LastName")
private String lastName;
@Column(name = "Password")
private String password;
@Column(name = "Enabled")
private boolean enabled;
@Column(name = "Role")
private String role;
// getters and setters
}
Now , I have got a model Tourism_Question_Table
(specific to each role I have) to create
@Entity ( name = Tourism_Questions_Table)
public class TourismQuestion {
@Id
@Column(name = "QuestionId")
private int questionId;
@Column(name = "Question")
private String question;
@Column(name = "TimeAsked")
private Date timeAsked;
// getters and setters
}
// Third model , reflects the data on who asked the question
// I have a requirement to take email as a Primary key from the Real_User
// table
// and questionId as a foreign key from the Tourism_Questions_Table
@Entity ( name = Tourism_User_Questions)
public class TourismUserQuestions {
// what's should be the hibernate annotations for these below two fields ?
private String email;
private int questionId;
// getters and setters
}
// For this last model I have to take email from the Real_User_Table
// and questionId from the Tourism_Questions_Table and makes them as
// the composite key in it to the reflect on who answered the question
@Entity ( name = Tourism_Answer_Table)
public class TourismAnswer {
// what's should be the hibernate annotations for these below two fields ?
private String email;
private int questionId;
private String answer;
// getters and setters
}
Need your help mates