www.pudn.com > ssh1.rar > AccountDaoImpl.java


/** 
 *  
 */ 
package com.tarena.dao.hibernate; 
 
import java.util.List; 
 
import org.springframework.orm.hibernate3.support.HibernateDaoSupport; 
 
import com.tarena.account.persistence.Account; 
import com.tarena.dao.IAccountDao; 
 
/** 
 * @author dong xuyuan 
 * 
 */ 
public class AccountDaoImpl extends HibernateDaoSupport implements IAccountDao { 
 
	public List queryAccounts(String username) { 
		 
		StringBuffer hql = new StringBuffer("from Account a where a.username ='" + username + "'"); 
		 
		return this.getHibernateTemplate().find(hql.toString()); 
	} 
 
	public void registerAccount(String username, String password, String desc) { 
		Account account = new Account(); 
		account.setUsername(username); 
		account.setPassword(password); 
		account.setDescription(desc); 
		 
		this.getHibernateTemplate().save(account); 
		System.out.println("Successfully create an account : " + username + ",  " + desc); 
	} 
 
}