userinfodaoimpl.java
来自「Struts+Spring+Hibernate实现的在线拍卖系统,去掉了这些组件」· Java 代码 · 共 120 行
JAVA
120 行
package org.bestteam.dao.impl;
import java.util.List;
import org.bestteam.dao.UserInfoDao;
import org.bestteam.domain.UserInfo;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class UserInfoDaoImpl extends HibernateDaoSupport implements UserInfoDao {
public static UserInfo getFromApplicationContext(ApplicationContext ctx) {
return (UserInfo) ctx.getBean("userInfoDao");
}
public boolean attachClean(UserInfo instance) {
try{
getHibernateTemplate().lock(instance, LockMode.NONE);
}catch(RuntimeException re) {
re.printStackTrace();
return false;
}
return true;
}
public boolean attachDirty(UserInfo instance) {
try{
getHibernateTemplate().saveOrUpdate(instance);
}catch(RuntimeException re) {
re.printStackTrace();
return false;
}
return true;
}
public boolean delete(UserInfo persistentInstance) {
try{
getHibernateTemplate().delete(persistentInstance);
}catch(RuntimeException re) {
re.printStackTrace();
return false;
}
return true;
}
public UserInfo findUserInfoByUserID(Integer userID) {
UserInfo user = null;
try{
user = (UserInfo) getHibernateTemplate().get("org.bestteam.domain.UserInfo", userID);
}catch(RuntimeException re) {
re.printStackTrace();
}
return user;
}
public List findUserInfoListByExample(UserInfo instance) {
List userList = null;
try{
userList = getHibernateTemplate().findByExample(instance);
}catch(RuntimeException re) {
re.printStackTrace();
}
return userList;
}
public List findUserInfoListByProperty(String propertyName, Object value) {
List userList = null;
try{
String queryString = "from UserInfo as userInfo where userInfo."
+ propertyName + "=?";
userList = getHibernateTemplate().find(queryString, value);
if (userList.size() == 0) {
userList = null;
}
}catch(RuntimeException re) {
re.printStackTrace();
}
return userList;
}
public List findAllUserInfo(){
List userList = null;
try{
String queryString = "from UserInfo as userInfo";
userList = getHibernateTemplate().find(queryString);
}catch(RuntimeException re) {
re.printStackTrace();
}
return userList;
}
public UserInfo merge(UserInfo detachedInstance) {
UserInfo user = null;
try{
user = (UserInfo) getHibernateTemplate().merge(detachedInstance);
}catch(RuntimeException re) {
re.printStackTrace();
}
return user;
}
public boolean save(UserInfo transientInstance) {
try{
getHibernateTemplate().save(transientInstance);
}catch(RuntimeException re) {
re.printStackTrace();
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?