public User login(String userName, String password) throws Exception {
   Session session = HibernateSessionFactory.getSession();
   try {
     UserDAO dao = new UserDAO();
     return dao.login(userName, PasswordEncryptor.md5(password));
   } finally {
     HibernateSessionFactory.closeSession();
   }
 }
  public Integer createUser(
      Date birthdate,
      TEthnicity ethnicity,
      TSex sex,
      TSex sexLookingFor,
      Integer height,
      TColor eyeColor,
      TColor hairColor,
      TChoice smoke,
      TChoice drink,
      THasChildren haveChildren,
      TWantsChildren wantsMoreChildren,
      TMaritalStatus maritalStatus,
      TBodytype userBodyType,
      String catchphrase,
      String aboutme,
      Integer idealHeightStart,
      Integer idealHeightEnd,
      TChoice idealSmokes,
      TChoice idealDrinks,
      THasChildren idealHasChildren,
      TWantsChildren idealWantsChildren,
      TMaritalStatus idealMaritalStatus,
      Integer termserviceagreement,
      Integer profileStatus,
      Zipcode zipcode,
      String password,
      String username,
      String email,
      List idealEthnicities,
      List idealBodyTypes,
      List idealLookingfor,
      Zipcode idealZipcode,
      Integer idealAgeStart,
      Integer idealAgeEnd,
      Integer idealDistance)
      throws Exception {
    Session session = HibernateSessionFactory.getSession();
    Transaction transaction = session.beginTransaction();
    User user = new User();
    try {
      user.setEthnicity(ethnicity);
      user.setBirthdate(birthdate);
      user.setSex(sex);
      user.setSexLookingFor(sexLookingFor);
      user.setEyeColor(eyeColor);
      user.setHairColor(hairColor);
      user.setHeight(height);
      user.setSmoke(smoke);
      user.setDrink(drink);
      user.setHaveChildern(haveChildren);
      user.setWantChildern(wantsMoreChildren);
      user.setMaritalStatus(maritalStatus);
      user.setBodyType(userBodyType);
      user.setCatchphrase(catchphrase);
      user.setAboutme(aboutme);
      user.setIdealHeightStart(idealHeightStart);
      user.setIdealHeightEnd(idealHeightEnd);
      user.setIdealSmokes(idealSmokes);
      user.setIdealDrinks(idealDrinks);
      user.setIdealHasChildern(idealHasChildren);
      user.setIdealWantsChildern(idealWantsChildren);
      user.setIdealMaritalStatus(idealMaritalStatus);
      user.setTermserviceagreement(termserviceagreement);
      user.setProfileStatus(profileStatus);
      user.setZipcode(zipcode);
      user.setPassword(PasswordEncryptor.md5(password));
      user.setUserName(username);
      user.setEmail(email);
      user.setIdealAgeStart(idealAgeStart);
      user.setIdealAgeEnd(idealAgeEnd);
      user.setIdealDistance(idealDistance);
      user.setIdealZipcode(idealZipcode);
      user.setIdealEthnicities(idealEthnicities);
      user.setIdealBodyTypes(idealBodyTypes);
      user.setIdealLookingfor(idealLookingfor);

      UserDAO dao = new UserDAO();
      dao.addUserOrUpdate(user);

      transaction.commit();
      return user.getUserId();
    } catch (Exception e) {
      transaction.rollback();
      throw e;
    } finally {
      HibernateSessionFactory.closeSession();
    }
  }