До сих пор я пробовал следующий код:
UserDate u;
SessionFactory sf=HibernateUtil.getSessionFactory();
Session session=sf.openSession();
session.beginTransaction();
Query queryResult = session.createQuery("from UserDate");
List<UserDate> l=queryResult.list();
for(int i=0; i<l.size(); i++) {
System.out.println(u.getClient_Name()+" "+u.getAppointementDate()+" "+u.getAssessment_year()+" "+u.getUnder_section());
}
Теперь мне нужно хранить все строки таблицы MySQL в одной переменной строки. UserDate - это сопоставленный класс. Кроме того, мне нужно использовать переменную, в которой будут храниться все строки, или же помочь найти способ хранения результатов используемого цикла for.
package p1;@Table(name = "user_dates")@Entity
public class UserDate {
@Id@GeneratedValue
private int dateId;
private String appointementDate;
private String reminderDate;
private String summary;
private String Client_Name;
private String assessment_year;
private int mailStatus;
public int getMailStatus() {
return mailStatus;
}
public void setMailStatus(int mailStatus) {
this.mailStatus = mailStatus;
}
public void setAssessment_year(String assessment_year) {
this.assessment_year = assessment_year;
}
public String getAssessment_year() {
return assessment_year;
}
private String under_section;@ManyToOne(targetEntity = Employee.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)@JoinColumn(name = "empID", referencedColumnName = "empID")
private Employee employee;
public int getDateId() {
return dateId;
}
public void setDateId(int dateId) {
this.dateId = dateId;
}
public String getAppointementDate() {
return appointementDate;
}
public void setAppointementDate(String appointementDate) {
this.appointementDate = appointementDate;
}
public String getReminderDate() {
return reminderDate;
}
public void setReminderDate(String reminderDate) {
this.reminderDate = reminderDate;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getClient_Name() {
return Client_Name;
}
public void setClient_Name(String client_Name) {
Client_Name = client_Name;
}
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public String getUnder_section() {
return under_section;
}
public void setUnder_section(String under_section) {
this.under_section = under_section;
}
}