TestuserDAO.java
上传用户:sz_mindeo
上传日期:2015-07-22
资源大小:913k
文件大小:7k
源码类别:

Ajax

开发平台:

Java

  1. package com.haiku.bean;
  2. import java.util.List;
  3. import org.apache.commons.logging.Log;
  4. import org.apache.commons.logging.LogFactory;
  5. import org.hibernate.LockMode;
  6. import org.hibernate.Query;
  7. import org.hibernate.Session;
  8. import org.hibernate.SessionFactory;
  9. import org.springframework.context.ApplicationContext;
  10. import org.springframework.context.support.ClassPathXmlApplicationContext;
  11. import org.springframework.orm.hibernate3.HibernateTemplate;
  12. import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
  13. /**
  14.  * A data access object (DAO) providing persistence and search support for
  15.  * Testuser entities. Transaction control of the save(), update() and delete()
  16.  * operations can directly support Spring container-managed transactions or they
  17.  * can be augmented to handle user-managed Spring transactions. Each of these
  18.  * methods provides additional information for how to configure it for the
  19.  * desired type of transaction control.
  20.  * 
  21.  * @see com.haiku.bean.Testuser
  22.  * @author MyEclipse Persistence Tools
  23.  */
  24. public class TestuserDAO extends HibernateDaoSupport {
  25. private static final Log log = LogFactory.getLog(TestuserDAO.class);
  26. // property constants
  27. public static final String PASSWORD = "password";
  28. protected void initDao() {
  29. // do nothing
  30. }
  31. /**
  32.  * 检测注册时的用户名是否可行!ajax的dwr框架调用该方法
  33.  * */
  34. public String checkRegisterName(Testuser transientInstance)
  35. {
  36. String flag="用户名有效";
  37. if(transientInstance.getUserName()==null)
  38. {
  39. return flag="用户名不可为空";
  40. }
  41. if(transientInstance.getUserName().length()< 3)
  42. {
  43. return flag="用户名不可小于三位";
  44. }
  45. Session session = this.getSession();
  46. Query query = session.createQuery("FROM Testuser where userName = ?");
  47. query.setString(0, transientInstance.getUserName());
  48. Object o = query.uniqueResult();
  49. session.beginTransaction().commit();
  50. session.close();
  51. if(o == null)
  52. {
  53. }
  54. else
  55. {
  56. return flag="该用户已被注册";
  57. }
  58. return flag;
  59. }
  60. /**
  61.  * 检册注释时的密码是否有效,(ajax的dwr框架调用该方法)
  62.  * */
  63. public String checkRegisterPassword(Testuser transientInstance)
  64. {
  65. System.out.println("到这个鬼地方判断密码");
  66. String flag = "密码有效,请提交";
  67. if(transientInstance.getPassword()==null)
  68. {
  69. return flag="密码不可为空值";
  70. }
  71. if(transientInstance.getPassword().length()<6)
  72. {
  73. return flag="密码不能小于6位";
  74. }
  75. return flag;
  76. }
  77. /**
  78.  * 检测登陆的用户名