TestuserDAO.java
资源名称:Ajax.rar [点击查看]
上传用户:sz_mindeo
上传日期:2015-07-22
资源大小:913k
文件大小:7k
源码类别:
Ajax
开发平台:
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;
- }
- /**
- * 检测登陆的用户名