在开始SSH实际应用之后,发现利用Hibernate Reverse Engineering自动生成的DAO中出了常见的save(),delete(),finAll(),finById()之外还有很多不知道干什么用的方法。遂查找资料做此笔记,方便以后温习备用。
package com.travis.DAO;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* A data access object (DAO) providing persistence and search support for User
* entities. Transaction control of the save(), update() and delete() operations
* can directly support Spring container-managed transactions or they can be
* augmented to handle user-managed Spring transactions. Each of these methods
* provides additional information for how to configure it for the desired type
* of transaction control.
*
* @see com.travis.DAO.User
* @author MyEclipse Persistence Tools
*/
public class UserDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(UserDAO.class);
// property constants
public static final String USER_NAME = "userName";
public static final String USER_PASSWORD = "userPassword";
protected void initDao() {
// do nothing
}
public void save(User transientInstance) {
log.debug(