public class Member implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Integer memberId;
private String memberName;
private String password;
private Integer usableRoleId;
private String telePhone;
private String mobilePhone;
private String address;
private String email;
private String homePage;
private Integer loginNumber;
private String isEnabled;
private java.sql.Timestamp buildDate;
private String portrait;
private java.sql.Timestamp lastLoginDate;
private Set articleComments = new HashSet(0);
private Set products = new HashSet(0);
private Set news = new HashSet(0);
private Set articles = new HashSet(0);
private Set productComments = new HashSet(0);
private Set usableRoles = new HashSet(0);
// Property accessors
public Integer getMemberId() {
return this.memberId;
}
public void setMemberId(Integer memberId) {
this.memberId = memberId;
}
public String getMemberName() {
return this.memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getUsableRoleId() {
return this.usableRoleId;
}
public void setUsableRoleId(Integer usableRoleId) {
this.usableRoleId = usableRoleId;
}
public String getTelePhone() {
return this.telePhone;
}
public void setTelePhone(String telePhone) {
this.telePhone = telePhone;
}
public String getMobilePhone() {
return this.mobilePhone;
}
public void setMobilePhone(String mobilePhone) {
this.mobilePhone = mobilePhone;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getHomePage() {
return this.homePage;
}
public void setHomePage(String homePage) {
this.homePage = homePage;
}
public Integer getLoginNumber() {
return this.loginNumber;
}
public void setLoginNumber(Integer loginNumber) {
this.loginNumber = loginNumber;
}
public String getIsEnabled() {
return this.isEnabled;
}
public void setIsEnabled(String isEnabled) {
this.isEnabled = isEnabled;
}
public java.sql.Timestamp getBuildDate() {
return this.buildDate;
}
public void setBuildDate(String buildDate) {
this.buildDate = new Timestamp(System.currentTimeMillis());
}
public String getPortrait() {
return this.portrait;
}
public void setPortrait(String portrait) {
this.portrait = portrait;
}
public java.sql.Timestamp getLastLoginDate() {
return this.lastLoginDate;
}
public void setLastLoginDate(String lastLoginDate) {
this.lastLoginDate=java.sql.Timestamp.valueOf(lastLoginDate);
}
public Set getArticleComments() {
return this.articleComments;
}
public void setArticleComments(Set articleComments) {
this.articleComments = articleComments;
}
public Set getProducts() {
return this.products;
}
public void setProducts(Set products) {
this.products = products;
}
public Set getNews() {
return this.news;
}
public void setNews(Set news) {
this.news = news;
}
public Set getArticles() {
return this.articles;
}
public void setArticles(Set articles) {
this.articles = articles;
}
public Set getProductComments() {
return this.productComments;
}
public void setProductComments(Set productComments) {
this.productComments = productComments;
}
public Set getUsableRoles() {
return this.usableRoles;
}
public void setUsableRoles(Set usableRoles) {
this.usableRoles = usableRoles;
}
}
问题点数:50 回复次数:13 显示所有回复显示星级回复显示楼主回复 修改 删除 举报 引用 回复
加为好友
发送私信
在线聊天
songfuqiang
拉帮结伙
等级:
发表于:2008-06-05 15:31:041楼 得分:0
接到上面的:
hbm.xml文件
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.jgssdw.hbm.Member" table="member" schema="dbo" catalog="ssdw">
<id name="memberId" type="java.lang.Integer">
<column name="memberId" />
<generator class="identity"> </generator>
</id>
<property name="memberName" type="java.lang.String">
<column name="memberName" length="20" />
</property>
<property name="password" type="java.lang.String">
<column name="password" length="20" />
</property>
<property name="usableRoleId" type="java.lang.Integer">
<column name="usableRoleId" />
</property>
<property name="telePhone" type="java.lang.String">
<column name="telePhone" length="20" />
</property>
<property name="mobilePhone" type="java.lang.String">
<column name="mobilePhone" length="20" />
</property>
<property name="address" type="java.lang.String">
<column name="Address" length="50" />
</property>
<property name="email" type="java.lang.String">
<column name="email" length="20" />
</property>
<property name="homePage" type="java.lang.String">
<column name="homePage" length="20" />
</property>
<property name="loginNumber" type="java.lang.Integer">
<column name="loginNumber" />
</property>
<property name="isEnabled" type="java.lang.String">
<column name="isEnabled" length="5" />
</property>
<property name="buildDate" type="java.sql.Timestamp">
<column name="buildDate" length="23" />
</property>
<property name="portrait" type="java.lang.String">
<column name="portrait" length="50" />
</property>
<property name="lastLoginDate" type="java.sql.Timestamp">
<column name="lastLoginDate" length="23" />
</property>
<set name="articleComments" inverse="true">
<key>
<column name="memberId" not-null="true" />
</key>
<one-to-many class="com.jgssdw.hbm.ArticleComment" />
</set>
<set name="products" inverse="true">
<key>
<column name="memberId" not-null="true" />
</key>
<one-to-many class="com.jgssdw.hbm.Product" />
</set>
<set name="news" inverse="true">
<key>
<column name="memberId" not-null="true" />
</key>
<one-to-many class="com.jgssdw.hbm.New" />
</set>
<set name="articles" inverse="true">
<key>
<column name="memberId" not-null="true" />
</key>
<one-to-many class="com.jgssdw.hbm.Article" />
</set>
<set name="productComments" inverse="true">
<key>
<column name="memberId" not-null="true" />
</key>
<one-to-many class="com.jgssdw.hbm.ProductComment" />
</set>
<set name="usableRoles" inverse="true">
<key>
<column name="memberId" />
</key>
<one-to-many class="com.jgssdw.hbm.UsableRole" />
</set>
</class>
</hibernate-mapping>
测试代码:
Session session=HibernateSessionFactory.getSession();
Transaction tran=session.beginTransaction();
Member member=new Member();
member.setAddress("address");
member.setHomePage("http://www.zgdsc.cn");
member.setIsEnabled("true");
member.setMemberId(new Integer(1));
member.setLastLoginDate("2008-12-12 12:25:25.0");
session.save(member);
tran.commit();