📄 userinfohibernatedao.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);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -