Spring2.5+Struts2+Hibernate3整合之三
2014-07-21 09:10
323 查看
转载请注明:来自http://blog.csdn.net/M_ChangGong/
作者:张燕广
该篇主要编写bean和bean的hibernate配置文件。
在src下创建包com.zyg.ssh.bean,在该包下创建bean类Student,其代码如下:
[b][java]
view plaincopy[/b]
package com.zyg.ssh.bean;
public class Student {
private Integer stuId;
private String stuName;
public Student() {}
public Student(String stuName) {
this.stuName = stuName;
}
public Integer getStuId() {
return stuId;
}
public void setStuId(Integer stuId) {
this.stuId = stuId;
}
public String getStuName() {
return stuName;
}
public void setStuName(String stuName) {
this.stuName = stuName;
}
@Override
public String toString() {
String result = "学号:"+this.stuId+",姓名:"+this.stuName;
return result;
}
}
在包com.zyg.ssh.bean下创建bean的hibernate配置文件Student.hbm.xml,其代码如下:
[b][xhtml]
view plaincopy[/b]
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Tue Aug 14 18:57:22 CST 2007 -->
<hibernate-mapping package="com.zyg.ssh.bean">
<class name="Student" table="student">
<id name="stuId" column="stuId">
<generator class="native"/>
</id>
<property name="stuName" length="20" not-null="true" column="stuname"/>
</class>
</hibernate-mapping>
[b]至此,该篇完成了bean类Student以及其hibernate配置文件Student.hbm.xml的编写。下一篇开始编写DAO层代码。[/b]
作者:张燕广
该篇主要编写bean和bean的hibernate配置文件。
在src下创建包com.zyg.ssh.bean,在该包下创建bean类Student,其代码如下:
[b][java]
view plaincopy[/b]
package com.zyg.ssh.bean;
public class Student {
private Integer stuId;
private String stuName;
public Student() {}
public Student(String stuName) {
this.stuName = stuName;
}
public Integer getStuId() {
return stuId;
}
public void setStuId(Integer stuId) {
this.stuId = stuId;
}
public String getStuName() {
return stuName;
}
public void setStuName(String stuName) {
this.stuName = stuName;
}
@Override
public String toString() {
String result = "学号:"+this.stuId+",姓名:"+this.stuName;
return result;
}
}
在包com.zyg.ssh.bean下创建bean的hibernate配置文件Student.hbm.xml,其代码如下:
[b][xhtml]
view plaincopy[/b]
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Tue Aug 14 18:57:22 CST 2007 -->
<hibernate-mapping package="com.zyg.ssh.bean">
<class name="Student" table="student">
<id name="stuId" column="stuId">
<generator class="native"/>
</id>
<property name="stuName" length="20" not-null="true" column="stuname"/>
</class>
</hibernate-mapping>
[b]至此,该篇完成了bean类Student以及其hibernate配置文件Student.hbm.xml的编写。下一篇开始编写DAO层代码。[/b]
相关文章推荐
- Spring2.5+Struts2+Hibernate3整合之五
- Spring2.5+Struts2+ Hibernate3整合之二
- Spring2.5+Struts2+Hibernate3整合之六
- Spring2.5+Struts2+Hibernate3整合之四
- Spring2.5+Struts2+Hibernate3整合之三
- Spring2.5+Struts2+Hibernate3整合之一
- Spring2.5+Struts2+Hibernate3整合之六
- Spring2.5+Struts2+ Hibernate3整合之二
- Spring2.5+Struts2+Hibernate3整合之四
- Spring2.5+Struts2+Hibernate3整合之一
- Spring2.5+Struts2+Hibernate3整合之五
- Struts2+Spring3+Hibernate3整合
- spring2.5+struts2.1.8+hibernate3整合配置
- Spring2.5+Struts2+Ibatis整合之一
- struts2+hibernate3+spring2.5整合配置
- SSH整合开发[Spring2.5+Hibernate3.3+Struts2]
- 框架学习之Spring 第五节 SSH整合开发[Spring2.5+Hibernate3.3+Struts2]
- 框架学习之Spring 第五节 SSH整合开发[Spring2.5+Hibernate3.3+Struts2]
- Struts2+Spring2.5+Hibernate3整合
- Spring2.5+Struts2+Ibatis整合之一