⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testuserdao.java

📁 Ajax(DWR) + Spring + Hibernate + Struts整合登陆注册.使用者可以作为入门资料
💻 JAVA
字号:
package com.haiku.bean;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * A data access object (DAO) providing persistence and search support for
 * Testuser 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.haiku.bean.Testuser
 * @author MyEclipse Persistence Tools
 */

public class TestuserDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(TestuserDAO.class);
	// property constants
	public static final String PASSWORD = "password";

	protected void initDao() {
		// do nothing
	}
	/**
	 * 检测注册时的用户名是否可行!ajax的dwr框架调用该方法
	 * */
	public String checkRegisterName(Testuser transientInstance)
	{
		String flag="用户名有效";
		if(transientInstance.getUserName()==null)
		{
			return flag="用户名不可为空";
		}
		if(transientInstance.getUserName().length()< 3)
		{
			return flag="用户名不可小于三位";
		}
		Session session = this.getSession();
		
		Query query = session.createQuery("FROM Testuser where userName = ?");
		query.setString(0, transientInstance.getUserName());
		Object o = query.uniqueResult();
		session.beginTransaction().commit();
		session.close();
		if(o == null)
		{
		}
		else
		{
			return flag="该用户已被注册";
		}
		
		return flag;
	}
	/**
	 * 检册注释时的密码是否有效,(ajax的dwr框架调用该方法)
	 * */
	public String checkRegisterPassword(Testuser transientInstance)
	{
		System.out.println("到这个鬼地方判断密码");
		String flag = "密码有效,请提交";
		if(transientInstance.getPassword()==null)
		{
			return flag="密码不可为空值";
		}
		if(transientInstance.getPassword().length()<6)
		{
			return flag="密码不能小于6位";
		}
		return flag;
	}
	
	/**
	 * 检测登陆的用户名

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -