package com.service;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;
import com.entity.Student;
@Component
public class StudentCrud {
@Resource
private HibernateTemplate hibernateTemplate;
public void saveStudent(Student s) {
hibernateTemplate.save(s);
};
// public void deleteStudent(Student s){
// hibernateTemplate.delete(s);
// };
// 删除
public void deleteStudent(Student s) {
System.out.println("dd"+s.getName());
// hibernateTemplate.delete(s); 删除单条必须知道id
hibernateTemplate.bulkUpdate("delete Student where name=?", new Object[]{s.getName()});//删除多条
System.out.println("dd11");
}
// 更新
public void updateStudent(Student s) {
// hibernateTemplate.update(s);//单条必须知道id
hibernateTemplate.bulkUpdate("update Student set classnum=? where name=?", new Object[]{s.getClassnum(),s.getName()});//多条
};
// public void findStudent(Student s){
// hibernateTemplate.find("select name from student where name=?");
// };
// 查询
public List getList(String hql, Student s) {
List list = hibernateTemplate.find(hql, new Object[]{s.getName()});
/*
* list = this.getHibernateTemplate().executeFind(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery(hql);
query.setFirstResult(pageNo);
query.setMaxResults(pageSize);
List list = query.list();
return list;
}
});
*/
return list;
}
public HibernateTemplate getHibernateTemplate() {
return hibernateTemplate;
}
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public StudentCrud() {
super();
// TODO Auto-generated constructor stub
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
自己写的简单的ssh的增删改查demo,用annotation注解的
共84个文件
jar:59个
jsp:6个
xml:5个
4星 · 超过85%的资源 需积分: 15 26 下载量 88 浏览量
2013-04-07
10:33:27
上传
评论 2
收藏 21.67MB RAR 举报
温馨提示
数据库用的是mysql,用的时候自己创建一个叫ssha的数据库,然后部署后就可以运行起来了,没有花哨的页面展示,只有简单的逻辑,可以让初学ssh的人快速明白web的逻辑
资源推荐
资源详情
资源评论
收起资源包目录
ssha.rar (84个子文件)
ssha
.project 1KB
.mymetadata 285B
src
struts.xml 1KB
applicationContext.xml 3KB
com
service
StudentCrud.java 2KB
action
StudentAction.java 1KB
dao
entity
Student.java 759B
WebRoot
WEB-INF
classes
struts.xml 1KB
applicationContext.xml 3KB
com
service
StudentCrud.class 2KB
action
StudentAction.class 2KB
dao
entity
Student.class 1KB
lib
asm.jar 26KB
jboss-jmx.jar 578KB
hibernate-commons-annotations.jar 65KB
ant-launcher-1.6.5.jar 9KB
ant-junit-1.6.5.jar 72KB
spring.jar 2.81MB
javassist-3.7.ga.jar 531KB
dom4j-1.6.1.jar 307KB
oscache-2.1.jar 112KB
syndiag2.jar 139KB
asm-attrs.jar 16KB
concurrent-1.3.2.jar 167KB
commons-pool.jar 61KB
xwork-core-2.2.1.1.jar 997KB
cglib-nodep-2.1_3.jar 317KB
jdbc2_0-stdext.jar 7KB
ant-antlr-1.6.5.jar 6KB
ant-1.6.5.jar 1010KB
cleanimports.jar 139KB
ant-swing-1.6.5.jar 7KB
jboss-system.jar 218KB
xerces-2.6.2.jar 987KB
jboss-cache.jar 505KB
jaas.jar 102KB
connector.jar 18KB
commons-dbcp.jar 119KB
antlr-2.7.6.jar 433KB
jacc-1_0-fr.jar 24KB
jaxen-1.1-beta-7.jar 222KB
swarmcache-1.0rc2.jar 30KB
struts2-dojo-plugin-2.2.1.1.jar 1.65MB
javassist.jar 449KB
aspectjweaver.jar 1.47MB
struts2-core-2.2.1.1.jar 755KB
commons-logging.jar 59KB
checkstyle-all.jar 1.15MB
commons-io-1.3.2.jar 86KB
jgroups-2.2.8.jar 1.54MB
hibernate3.jar 2.08MB
jboss-common.jar 570KB
ehcache-1.2.jar 115KB
commons-fileupload-1.2.1.jar 56KB
cglib-2.1.3.jar 276KB
freemarker-2.3.16.jar 860KB
ognl-3.0.jar 224KB
ejb3-persistence.jar 49KB
proxool-0.8.3.jar 465KB
struts2-spring-plugin-2.2.1.1.jar 21KB
c3p0-0.9.0.jar 476KB
junit-3.8.1.jar 118KB
aspectjrt.jar 112KB
hibernate-annotations.jar 355KB
mysql-connector-java-5.1.13.jar 750KB
versioncheck.jar 6KB
commons-logging-1.0.4.jar 37KB
log4j-1.2.11.jar 342KB
commons-collections-2.1.1.jar 171KB
jta.jar 9KB
xml-apis.jar 121KB
web.xml 983B
index.jsp 827B
find.jsp 821B
update.jsp 824B
META-INF
MANIFEST.MF 36B
ok.jsp 2KB
save.jsp 822B
delete.jsp 824B
.myeclipse
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.jsdt.ui.superType.name 6B
.jsdtscope 500B
.classpath 5KB
共 84 条
- 1
资源评论
- mfmyy112013-09-25不适合最新的
zhonghuahuizi
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功