8.5.2对持久化对象的分析
BookBrowse.java、Books.java和UserTable.java三个生成的类是标准的JavaBean,Hibernate插件根据数据库的表结构自动生成了这三个持久化对象,对于每个属性都有其对应的getter/setter方法。
注意:这三个类中的英文注释是Hibernate插件自动生成的,为了便于读者的理解,这里加上了部分中文注释。
(1)BookBrowse.java文件是标准的JavaBean对应于demo数据库中的bookbrowse表,包括学生姓名、书名、归还日期、借阅日期、备注和是否归还等信息,内容如下所示:
package library.hibernate;
// Generated 2006-8-5 16:17:23 by Hibernate Tools 3.1.0 beta3
import java.util.Date;
/**
* BookBrowse generated by hbm2java
*/
public class BookBrowse implements java.io.Serializable {
// Fields
//学生名字
private String studentName;
//书名
private String bookName;
//归还日期
private Date returnDate;
//借阅日期
private Date borrowDate;
//备注,评论信息
private String com;
//是否归还
private String isReturned;
// Constructors
/** 缺省构造函数 */
public BookBrowse() {
}
/** minimal constructor */
public BookBrowse(String studentName) {
this.studentName = studentName;
}
/** full constructor */
public BookBrowse(String studentName, String bookName,
Date returnDate, Date borrowDate, String com, String isReturned) {
this.studentName = studentName;
this.bookName = bookName;
this.returnDate = returnDate;
this.borrowDate = borrowDate;
this.com = com;
this.isReturned = isReturned;
}
// Property accessors 取得学生姓名
public String getStudentName() {
return this.studentName;
}
//设置学生姓名
public void setStudentName(String studentName) {
this.studentName = studentName;
}
//取得书名字段的值
public String getBookName() {
return this.bookName;
}
//设置书名字段
public void setBookName(String bookName) {
this.bookName = bookName;
}
//取得归还日期字段
public Date getReturnDate() {
return this.returnDate;
}
//设置归还日期字段
public void setReturnDate(Date returnDate) {
this.returnDate = returnDate;
}
//取得借阅日期
public Date getBorrowDate() {
return this.borrowDate;
}
//设置借阅日期
public void setBorrowDate(Date borrowDate) {
this.borrowDate = borrowDate;
}
//取得备注信息
public String getCom() {
return this.com;
}
//设置备注信息
public void setCom(String com) {
this.com = com;
}
//取得是否归还状态
public String getIsReturned() {
return this.isReturned;
}
//设置是否归还状态
public void setIsReturned(String isReturned) {
this.isReturned = isReturned;
}
}
|
(2)Books.java类对应于demo数据库中的books表,是标准的JavaBean,包括书名、出版社、作者、地址、出版日期、价格等相关信息,其代码如下所示:
package library.hibernate;
// Generated 2006-8-5 16:17:23 by Hibernate Tools 3.1.0 beta3
import java.util.Date;
/**
* Books generated by hbm2java
*/
public class Books implements java.io.Serializable {
// Fields
//书名
private String bookName;
//出版社
private String press;
//作者
private String author;
//地址
private String address;
//出版日期
private Date pressDate;
//价格
private Double price;
//备注
private String com;
//图书数量
private Integer booksCount;
//已借阅数量
private Integer borrowedCount;
// Constructors
/** default constructor */
public Books() {
}
/** minimal constructor */
public Books(String bookName) {
this.bookName = bookName;
}
/** full constructor */
public Books(String bookName, String press, String author,
String address, Date pressDate, Double price, String com,
Integer booksCount, Integer borrowedCount) {
this.bookName = bookName;
this.press = press;
this.author = author;
this.address = address;
this.pressDate = pressDate;
this.price = price;
this.com = com;
this.booksCount = booksCount;
this.borrowedCount = borrowedCount;
}
// Property accessors
//取得书名属性的值
public String getBookName() {
return this.bookName;
}
//设置书名属性
public void setBookName(String bookName) {
this.bookName = bookName;
}
//取得出版社字段的值
public String getPress() {
return this.press;
}
//设置出版社字段
public void setPress(String press) {
this.press = press;
}
//取得作者信息
public String getAuthor() {
return this.author;
}
//设置作者信息
public void setAuthor(String author) {
this.author = author;
}
//取得地址信息
public String getAddress() {
return this.address;
}
//设置地址信息
public void setAddress(String address) {
this.address = address;
}
//取得出版日期
public Date getPressDate() {
return this.pressDate;
}
//设置出版日期
public void setPressDate(Date pressDate) {
this.pressDate = pressDate;
}
//取得价格信息
public Double getPrice() {
return this.price;
}
//设置价格信息
public void setPrice(Double price) {
this.price = price;
}
//取得备注信息
public String getCom() {
return this.com;
}
//设置备注信息
public void setCom(String com) {
this.com = com;
}
//取得图书数量
public Integer getBooksCount() {
return this.booksCount;
}
//设置图书数量
public void setBooksCount(Integer booksCount) {
this.booksCount = booksCount;
}
//取得已借阅图书数量
public Integer getBorrowedCount() {
return this.borrowedCount;
}
//设置已借阅图书数量
public void setBorrowedCount(Integer borrowedCount) {
this.borrowedCount = borrowedCount;
}
}
|
(3)UserTable.java类对应于demo数据库中的usertable表,包括用户名、密码和用户权限三个属性,是标准的JavaBean,其代码如下所示:
package library.hibernate;
// Generated 2006-8-5 16:17:23 by Hibernate Tools 3.1.0 beta3
/**
* UserTable generated by hbm2java
*/
public class UserTable implements java.io.Serializable {
// Fields
//用户名
private String userName;
//密码
private String password;
//用户权限
private String power;
// Constructors
/** default constructor */
public UserTable() {
}
/** minimal constructor */
public UserTable(String userName) {
this.userName = userName;
}
/** full constructor */
public UserTable(String userName, String password, String power) {
this.userName = userName;
this.password = password;
this.power = power;
}
// Property accessors
//取得用户名字段
public String getUserName() {
return this.userName;
}
//设置用户名字段
public void setUserName(String userName) {
this.userName = userName;
}
//取得密码字段
public String getPassword() {
return this.password;
}
//设置密码字段
public void setPassword(String password) {
this.password = password;
}
//取得用户权限
public String getPower() {
return this.power;
}
//设置用户权限
public void setPower(String power) {
this.power = power;
}
}
|
| 回书目 上一节 下一节 |
|
· Linux笔试面试题选摘测.. · 08年5月软考网管上午真.. · 性能测试从零开始 目录 · 08年5月软考网工上午真.. · 上周拒绝服务攻击(DDo.. · 08年5月各大网上书店及.. |
· 2008年5月24日软考试题.. · 软件设计师专家临考模.. · 上周网络管理员专家自.. · 网络工程师自测获奖名.. · 08年4月各大网上书店及.. · 系统分析师自测获奖名.. |
|
||||
| · ASP.NET开发教程 · 专题:ASP.NET 2.0基础.. · LAMP技术精解 · 服务器节能与绿色IT · ARP攻击防范与解决方案 · Linux 集群技术专题 · Windows集群服务应用 · CISSP认证成长之路 |
· SQL Server 2008/2005.. · SQL Server入门到精通 · 网络工程师职业规划与.. · 浏览器的战国时代 · 运营商封堵ADSL共享 中.. · 微软出价446亿美元收购.. · 技术人求职简历完备手册 · 开源虚拟化技术Xen |
|||
|
||||
| · SOA 面向服务架构 · SQL Server 2008/2005.. · Apache技术专题 · 三层交换技术专题 · SQL Server入门到精通 · Apache技术专题 · Windows集群服务应用 · 国际文档格式标准开战 |
· 路由器设置与口令恢复 · Linux 集群技术专题 · PHP开发应用手册 · SOA 面向服务架构 · 企业数据恢复指南 · 了解统一威胁管理(UTM).. · 专题:AIX操作系统管理.. · 访问控制列表(ACL)介绍 |
|||
|
||||
| · SQL Server入门到精通 · SQL Server 2008/2005.. · SOA 面向服务架构 · Apache技术专题 · 三层交换技术专题 · Apache技术专题 · 企业数据恢复指南 · Windows集群服务应用 |
· 路由器设置与口令恢复 · Linux 集群技术专题 · SOA 面向服务架构 · 了解统一威胁管理(UTM).. · 反垃圾邮件技术应用 · 访问控制列表(ACL)介绍 · ASP.NET开发教程 · PHP开发应用手册 |
|||