时间戳实现乐观锁
Person.java
package cn.lxl.pojo;public class Person {private Integer id;private String username;private String password;//设置一个属性,时间戳实现乐观锁//不提供 setter和 getter方法private java.sql.Timestamp updateTime;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}}
?
Person.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"><hibernate-mapping><class name="cn.lxl.pojo.Person" table="t_Person"><id name="id"><generator column="update_time" access="field" ></timestamp><property name="username"><column name="username"></column></property><property name="password"><column name="password"></column></property></class></hibernate-mapping>
?