Hibernate Development in MyEclipse5.1.0 (Eclipse3.2 Kernel)
我们采用如下的简单例子来进行说明:
两个在MySql环境下设计的Table
T_Account_Info, T_DEPT_INFO
其中
T_Account_Info refer T_Dept_Info,
T_Account_Info的field dept_Number refer T_Dept_Info’s Primary key dept_Number
(1)The dbase design is as following:
(2)create dbase connection in MyEclipse5.1.0
(3) use existed dbase to Reversely Create Hibernate mapping File and DAO file in MyEclipse Hibernate perspective
(4) create domain class according to hbm.xml
(5)Test created DAO
TAccountInfoDAO accountDao =
new
TAccountInfoDAO();
TAccountInfo accountInfo = accountDao.findById(2);
TDeptInfo deptInfo = accountInfo.getDeptInfo();
System.
out
.println(deptInfo.getDeptNumber());
System.
out
.println(deptInfo.getDeptName());
System.
out
.println(deptInfo.getDeptMembers());