package com.keke.hibernate;
import com.keke.hibername.BaseHibernateDAO;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
/**
* A data access object (DAO) providing persistence and search support for
* Student 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 com.keke.hibernate.Student
* @author MyEclipse Persistence Tools
*/
public class StudentDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(StudentDAO.class);
// property constants
public static final String STUDENT_NAME = "studentName";
public void save(Student transientInstance) {
log.debug("saving Student instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Student persistentInstance) {
log.debug("deleting Student instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Student findById(java.lang.Integer id) {
log.debug("getting Student instance with id: " + id);
try {
Student instance = (Student) getSession().get(
"com.keke.hibernate.Student", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Student instance) {
log.debug("finding Student instance by example");
try {
List results = getSession().createCriteria(
"com.keke.hibernate.Student").add(Example.create(instance))
.list();
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 Student instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Student as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByStudentName(Object studentName) {
return findByProperty(STUDENT_NAME, studentName);
}
public List findAll() {
log.debug("finding all Student instances");
try {
String queryString = "from Student";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Student merge(Student detachedInstance) {
log.debug("merging Student instance");
try {
Student result = (Student) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Student instance) {
log.debug("attaching dirty Student instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Student instance) {
log.debug("attaching clean Student instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
sqlserver.rar (49个子文件)
sqlserver
.project 2KB
.settings
.jsdtscope 500B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
.mymetadata 300B
WebRoot
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 405B
web.xml 1KB
struts-config.xml 788B
struts-bean.tld 9KB
struts-nested.tld 70KB
struts-html.tld 72KB
struts-logic.tld 14KB
validator-rules.xml 13KB
lib
sqljdbc.jar 570KB
classes
com
keke
hibernate
Student.hbm.xml 942B
StudentDAO.class 5KB
Student.class 1KB
struts
action
DbbaseAction.class 2KB
form
DbbaseForm.class 1KB
ApplicationResources.properties 85B
hibername
Test1Id.class 2KB
HibernateSessionFactory.class 3KB
Test1DAO.class 5KB
Test1.class 1KB
BaseHibernateDAO.class 514B
Test1.hbm.xml 799B
IBaseHibernateDAO.class 183B
hibernate.cfg.xml 1011B
index.jsp 834B
META-INF
MANIFEST.MF 36B
dbbase.jsp 1KB
.myeclipse
src
com
keke
hibernate
StudentDAO.java 4KB
Student.hbm.xml 942B
Student.java 1KB
struts
action
DbbaseAction.java 1KB
form
DbbaseForm.java 1KB
ApplicationResources.properties 85B
hibername
BaseHibernateDAO.java 315B
Test1DAO.java 4KB
Test1.java 874B
Test1.hbm.xml 799B
IBaseHibernateDAO.java 229B
Test1Id.java 2KB
HibernateSessionFactory.java 3KB
hibernate.cfg.xml 1011B
.mystrutsdata 255B
.classpath 735B
.myhibernatedata 599B
共 49 条
- 1
资源评论
pingfankeke
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- apk.tw_LineLite_v8a_v.2.17.1_sign.apk
- Elasticsearch实战:构建高效搜索系统的秘诀.zip
- HTML+CSS+JS网页设计:从入门到精通.zip
- 数据库课程设计:从理论到实践的全面指南.zip
- Python闭包:深入理解与应用场景解析.zip
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功