package com.dao;
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;
/**
* A data access object (DAO) providing persistence and search support for
* Students 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.dao.Students
* @author MyEclipse Persistence Tools
*/
public class StudentsDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(StudentsDAO.class);
protected void initDao() {
// do nothing
}
public void save(Students transientInstance) {
log.debug("saving Students instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Students persistentInstance) {
log.debug("deleting Students instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Students findById(java.lang.Integer id) {
log.debug("getting Students instance with id: " + id);
try {
Students instance = (Students) getHibernateTemplate().get(
"com.dao.Students", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Students instance) {
log.debug("finding Students 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 Students instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Students 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 findAll() {
log.debug("finding all Students instances");
try {
String queryString = "from Students";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Students merge(Students detachedInstance) {
log.debug("merging Students instance");
try {
Students result = (Students) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Students instance) {
log.debug("attaching dirty Students instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Students instance) {
log.debug("attaching clean Students instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public List findClass(String name) {
log.debug("finding all Students instances");
try {
String queryString = "from Students where name='"+name+"'";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public List findstudents(Integer cl) {
log.debug("finding all Students instances");
try {
String queryString = "from Students as stu where stu.classes="+cl+"";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public static StudentsDAO getFromApplicationContext(ApplicationContext ctx) {
return (StudentsDAO) ctx.getBean("StudentsDAO");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
用ssh做了一个供初学者使用学习的例子
共68个文件
java:13个
class:13个
xml:11个
4星 · 超过85%的资源 需积分: 3 10 下载量 32 浏览量
2008-10-25
22:55:28
上传
评论
收藏 1.31MB RAR 举报
温馨提示
用ssh框架做了一个学生与班级间查找的例子,对初学者来讲是一个很好的例子,涉及到主外键查找等···
资源推荐
资源详情
资源评论
收起资源包目录
spring.rar (68个子文件)
spring
testSpring_Log.LDF 1024KB
StudentTest
.mystrutsdata 262B
.springBeans 273B
.myhibernatedata 521B
src
JiechengIm.java 330B
applicationContext-trans.xml 1KB
com
dao
Classes.java 1KB
Students.hbm.xml 858B
StudentsDAO.java 5KB
Students.java 895B
ClassesDAO.java 4KB
Classes.hbm.xml 959B
form
SelStudentForm.java 1KB
SelClassForm.java 1KB
action
SelStudentAction.java 1KB
SelClassAction.java 1KB
yourcompany
struts
ApplicationResources.properties 94B
biz
SelClaStuImpl.java 1KB
SelClaStu.java 172B
hibernate
HibernateSessionFactory.java 3KB
applicationContext-bean.xml 2KB
Jiecheng.java 197B
.project 2KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
struts-nested.tld 70KB
validator-rules.xml 13KB
struts-bean.tld 9KB
struts-html.tld 72KB
struts-logic.tld 14KB
struts-tiles.tld 8KB
web.xml 1KB
.struts-config.mex 2KB
classes
applicationContext-trans.xml 1KB
com
dao
Classes.class 1KB
Students.hbm.xml 858B
ClassesDAO.class 5KB
StudentsDAO.class 5KB
Classes.hbm.xml 959B
Students.class 1KB
form
SelClassForm.class 1KB
SelStudentForm.class 1KB
action
SelStudentAction.class 2KB
SelClassAction.class 1KB
yourcompany
struts
ApplicationResources.properties 94B
biz
SelClaStu.class 221B
SelClaStuImpl.class 2KB
hibernate
HibernateSessionFactory.class 2KB
Jiecheng.class 547B
JiechengIm.class 558B
applicationContext-bean.xml 2KB
struts-config.xml 1KB
lib
mssqlserver.jar 66KB
msbase.jar 280KB
commons-pool-1.4.jar 85KB
msutil.jar 58KB
commons-logging.jar 52KB
commons-dbcp-1.2.2.jar 119KB
commons-collections-3.2.jar 558KB
spring-hibernate3.jar 105KB
spring.tld 13KB
spring-form.tld 51KB
selStudents.jsp 1KB
selClasses.jsp 876B
selStudent.jsp 529B
selClass.jsp 510B
.mymetadata 306B
.classpath 2KB
.myeclipse
testSpring_Data.MDF 1024KB
共 68 条
- 1
资源评论
- dingdingnihao12014-04-03貌似没有数据库……
lzzken
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于springboot+layui的医院日常耗材管理系统.zip
- 计算机毕业设计-ASP.NET教育报表管理系统-权限管理模块(源代码+)-毕设源码实例.zip
- 计算机毕业设计-ASP.NET教务信息管理系统的设计与实现(源代码+)-毕设源码实例.zip
- Eleven的精益供应链管理-碓胤咨询龚胤全.rar
- 5套光伏、储能、充电收益测算表.zip
- C2 供应链集成演示平台操作手册(详细版).rar
- 3套光储充一体化站CAD+PDF图纸.zip
- Screenshot_20240426_195831_com.huawei.android.launcher.jpg
- 2000-2023年各省专利侵权结案数据.xlsx
- C#使用NPOI操作合并单元格
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功