UserInfoHibernateDAO.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.dao.hibernate;
- import java.util.*;
- import org.springframework.orm.hibernate3.support.*;
- import com.opensource.blog.dao.UserInfoDAO;
- import com.opensource.blog.model.UserInfo;
- public class UserInfoHibernateDAO
- extends HibernateDaoSupport implements UserInfoDAO {
- private static final String LOAD_USERNAME = "from UserInfo where username = ?";
- private static final String LOAD_EMAIL = "from UserInfo where email = ?";
- public UserInfoHibernateDAO() {
- super();
- }
- /**
- *
- * @param ui UserInfo
- * @return UserInfo
- * @todo Implement this com.opensource.blog.dao.UserInfoDAO method
- */
- public UserInfo saveUserInfo(UserInfo ui) {
- this.getHibernateTemplate().saveOrUpdate(ui);
- return ui;
- }
- /**
- *
- * @param id long
- * @return UserInfo
- * @todo Implement this com.opensource.blog.dao.UserInfoDAO method
- */
- public UserInfo findUserInfoByID(long id) {
- return (UserInfo)this.getHibernateTemplate().get(UserInfo.class,
- new Long(id));
- }
- /**
- *
- * @param userName String
- * @return UserInfo
- * @todo Implement this com.opensource.blog.dao.UserInfoDAO method
- */
- public UserInfo findUserInfoByUserName(String userName) {
- List l = this.getHibernateTemplate().find(LOAD_USERNAME, userName);
- if (l == null || l.isEmpty()) {
- return null;
- }
- else {
- return (UserInfo) l.get(0);
- }
- }
- /**
- *
- * @param email String
- * @return UserInfo
- * @todo Implement this com.opensource.blog.dao.UserInfoDAO method
- */
- public UserInfo findUserInfoByEmail(String email) {
- List l = this.getHibernateTemplate().find(LOAD_EMAIL, email);
- if (l == null || l.isEmpty()) {
- return null;
- }
- else {
- return (UserInfo) l.get(0);
- }
- }
- }