看同事用了hibernate anotation,也记录一下吧

一直用的xxx.hbm.xml, 看同事用这种方式也挺方便的,学习一下

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="OBM_WORK_RESULT")
public class WorkResultEntity implements Serializable {

@Id
@Column(name="resultId", length=32)
private String id;
@Basic
@Column(name="reportContentId", length=32 )
private String reportContentId;
@Basic
@Column(name="quantity" )
private int quantity;
@Basic
@Column(name="hour" )
private int hour;
@Basic
@Column(name="issue" )
private int issue;
@Basic
@Column(name="bug" )
private int bug;
@Basic
@Column(name="createTime" )
private Date createTime;
@Basic
@Column(name="updateTime" )
private Date updateTime;

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getReportContentId() {
return reportContentId;
}
public void setReportContentId(String reportContentId) {
this.reportContentId = reportContentId;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getIssue() {
return issue;
}
public void setIssue(int issue) {
this.issue = issue;
}
public int getBug() {
return bug;
}
public void setBug(int bug) {
this.bug = bug;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}


}


applicationContext.xml中sessionFactory要使用AnnotationSessionFactoryBean

<bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.HSQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>org.chuck.data.model.entity.ProjectEntity</value>
<value>org.chuck.data.model.entity.WorkContentEntity</value>
<value>org.chuck.data.model.entity.WeeklyReportEntity</value>
<value>org.chuck.data.model.entity.FunctionEntity</value>
<value>org.chuck.data.model.entity.WorkResultEntity</value>
<value>org.chuck.data.model.entity.ReportContentEntity</value>
<value>org.chuck.data.model.entity.PersonEntity</value>
</list>
</property>
</bean>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值