Write the first hibernate example the second step: Create a Persistence class (the design principles of the persistence class follow JavaBeans design principles) JavaBeans design principles:
1. Common classes
2. Provide the default construction method of the public without parameters
3. Property Private
4. Attribute Setter/getter Encapsulation
Create a new students class (persisted class)
Import java.util.date;//Student public class Students {//1. Common class//2. Provides the default construction method of the public without parameters//3. Property Private//4. Property setter/ Getter Encapsulation private int sid;//number private string sname;//name private string gender;//sex private date birthday;//date of birth private Str ing address;//address public Students () {}public Students (int sid, String sname, String gender, Date birthday,string address) { Super (); this.sid = Sid;this.sname = Sname;this.gender = Gender;this.birthday = Birthday;this.address = Address;} public int GetSID () {return SID;} public void Setsid (int sid) {this.sid = SID;} Public String Getsname () {return sname;} public void Setsname (String sname) {this.sname = sname;} Public String Getgender () {return gender;} public void Setgender (String gender) {This.gender = gender;} Public Date Getbirthday () {return birthday;} public void Setbirthday (Date birthday) {this.birthday = birthday;} Public String getaddress () {return address;} public void setaddress (String address) {this.address = address;} @Overridepublic String toString () {return 'Students [sid= "+ Sid +", sname= "+ sname +", gender= "+ Gender +", birthday= "+ Birthday +", address= "+ address+"] "; }}
A single-table mapping of Hibernate--Creating persistent classes