我正在使用大量 SQL 表在 Web 应用程序中工作。我需要为每个表创建一个 java bean 类。我正在寻找一种可以将 SQL 表转换为 java bean 类的工具。这将有助于节省时间。
这是一个例子:
studentTable (studentId, firstname, lastname, yearLevel)
-->
public class Student {
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO)
private int studentId;
@Column
private String firstname;
@Column
private String lastname;
@Column
private int yearLevel;
public Student(){}
public Student(int studentId, String firstname, String lastname,
int yearLevel) {
super();
this.studentId = studentId;
this.firstname = firstname;
this.lastname = lastname;
this.yearLevel = yearLevel;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public int getYearLevel() {
return yearLevel;
}
public void setYearLevel(int yearLevel) {
this.yearLevel = yearLevel;
}
}
你对这样的工具有什么想法吗?