spring2.5 和Hibernate的注解的应用
?????? ??? <property name="annotatedClasses">
??? ??? ??? <list>
??? ??? ??? ??? <value>cn.f3.db.entity.LogonLog</value>
??? ??? ??? </list>
??? ??? </property>
??? ??? <property name="hibernateProperties">
??? ??? ??? <props>
??? ??? ??? ??? <prop key="hibernate.dialect">
??? ??? ??? ??? ??? org.hibernate.dialect.SQLServerDialect
??? ??? ??? ??? </prop>
??? ??? ??? ??? <prop key="hibernate.show_sql">true</prop>??? ??? ??? ????
??? ??? ??? </props>
??? ??? </property>
??? </bean>
????c.用注解解决实体Bean(cn.f3.db.entity.LogonLog)
??? @javax.persistence.Entity
@Entity(dynamicInsert=true)?? --??允许默认值?
@Table(name = "J_ZX_LogonLog")
public class LogonLog implements Serializable {
??? /**
??? ?*?
??? ?*/
??? private static final long serialVersionUID = 1L;
??? /**
??? ?* GUID
??? ?*/????
??? private String guid;
??? /**
??? ?* 登录工号
??? ?*/????
??? private String id;
??? /**
??? ?* 登录IP
??? ?*/????
??? private String ip;
??? /**
??? ?* 登录类型
??? ?*/????
??? private String type;
??? /**
??? ?* 登录时间
??? ?*/????
??? private Date writeTime;
??? @Id
??? @GeneratedValue(generator = "paymentableGenerator")????
??? @GenericGenerator(name = "paymentableGenerator", strategy = "guid")???
??? @Column(name = "FGuid", unique = true, nullable = false, length = 50)???--自动生成GUID?
??? public String getGuid() {
??? ??? return guid;
??? }
??? public void setGuid(String guid) {
??? ??? this.guid = guid;
??? }
??? @Column(name = "FID", nullable = false, length = 10)
??? public String getId() {
??? ??? return id;
??? }
??? public void setId(String id) {
??? ??? this.id = id;
??? }
??? @Column(name = "FIP", nullable = false, length = 50)
??? public String getIp() {
??? ??? return ip;
??? }
??? public void setIp(String ip) {
??? ??? this.ip = ip;
??? }
??? @Column(name = "FType", nullable = false)
??? public String getType() {
??? ??? return type;
??? }
??? public void setType(String type) {
??? ??? this.type = type;
??? }
??? @Temporal(TemporalType.DATE)
??? @Column(name = "FWriteTime", length = 23)
??? public Date getWriteTime() {
??? ??? return writeTime;
??? }
??? public void setWriteTime(Date writeTime) {
??? ??? this.writeTime = writeTime;
??? }
}
?
?? d、继承HibernateDaoSupport实现保存功能
?? public class LogonLogHibernateDao extends HibernateDaoSupport implements LogonLogDao {
???? public void addLogonLog(LogonLog logonLog) {
??? ??? getHibernateTemplate().save(logonLog);
??? }
}