package cn.com.semir.hibernate.DaoImpl;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import cn.com.semir.hibernate.Dao.LoginDAO;
import cn.com.semir.hibernate.PO.Login;
/**
* A data access object (DAO) providing persistence and search support for Login
* entities. Transaction control of the save(), update() and delete() operations
* can directly support Spring container-managed transactions or they can be
* augmented to handle user-managed Spring transactions. Each of these methods
* provides additional information for how to configure it for the desired type
* of transaction control.
*
* @see cn.com.semir.hibernate.PO.Login
* @author MyEclipse Persistence Tools
*/
public class LoginDaoImpl extends HibernateDaoSupport implements LoginDAO {
private static final Log log = LogFactory.getLog(LoginDaoImpl.class);
// property constants
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
protected void initDao() {
// do nothing
}
public void save(Login transientInstance) {
log.debug("saving Login instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Login persistentInstance) {
log.debug("deleting Login instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Login findById(java.lang.Integer id) {
log.debug("getting Login instance with id: " + id);
try {
Login instance = (Login) getHibernateTemplate().get(
"cn.com.semir.hibernate.PO.Login", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Login instance) {
log.debug("finding Login instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Login instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Login as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByUsername(Object username) {
return findByProperty(USERNAME, username);
}
public List findByPassword(Object password) {
return findByProperty(PASSWORD, password);
}
public List findAll() {
log.debug("finding all Login instances");
try {
String queryString = "from Login";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Login merge(Login detachedInstance) {
log.debug("merging Login instance");
try {
Login result = (Login) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Login instance) {
log.debug("attaching dirty Login instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Login instance) {
log.debug("attaching clean Login instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static LoginDaoImpl getFromApplicationContext(ApplicationContext ctx) {
return (LoginDaoImpl) ctx.getBean("LoginDAO");
}
public List check(String username, String password) {
return getHibernateTemplate().find("from Login where username='"+username+"'and password='"+password+"'");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
SSH.rar (43个子文件)
SSH
.project 2KB
.settings
.jsdtscope 406B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
.mymetadata 282B
WebRoot
success.jsp 814B
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 918B
web.xml 1KB
struts-config.xml 1KB
struts-bean.tld 9KB
spring-form.tld 71KB
struts-nested.tld 70KB
applicationContext.xml 2KB
struts-html.tld 72KB
spring.tld 13KB
struts-logic.tld 14KB
validator-rules.xml 13KB
lib
classes
cn
com
semir
hibernate
PO
Login.class 1KB
Login.hbm.xml 813B
Service
Service.class 184B
DaoImpl
LoginDaoImpl.class 6KB
Dao
LoginDAO.class 741B
ServiceImpl
ServiceImpl.class 1KB
struts
action
LoginAction.class 1KB
form
LoginForm.class 1KB
ApplicationResources.properties 83B
index.jsp 667B
META-INF
MANIFEST.MF 39B
err.jsp 813B
.myeclipse
src
cn
com
semir
hibernate
PO
Login.java 1KB
Login.hbm.xml 813B
Service
Service.java 171B
DaoImpl
LoginDaoImpl.java 5KB
Dao
LoginDAO.java 1KB
ServiceImpl
ServiceImpl.java 662B
struts
action
LoginAction.java 1KB
form
LoginForm.java 1KB
ApplicationResources.properties 83B
.mystrutsdata 259B
.springBeans 481B
.classpath 7KB
.myhibernatedata 575B
共 43 条
- 1
资源评论
- scamsjk2012-12-18太感谢楼主分享这么好的资源,等很久啦~~~,正需要
莫扎特_Mozart
- 粉丝: 25
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功