package com.xmetc.xmu.pojo;
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 Game
* 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.xmetc.xmu.pojo.Game
* @author MyEclipse Persistence Tools
*/
public class GameDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(GameDAO.class);
// property constants
public static final String NAMES = "names";
protected void initDao() {
// do nothing
}
public void save(Game transientInstance) {
log.debug("saving Game instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Game persistentInstance) {
log.debug("deleting Game instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Game findById(java.math.BigDecimal id) {
log.debug("getting Game instance with id: " + id);
try {
Game instance = (Game) getHibernateTemplate().get(
"com.xmetc.xmu.pojo.Game", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Game instance) {
log.debug("finding Game 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 Game instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Game 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 findByNames(Object names) {
return findByProperty(NAMES, names);
}
public List findAll() {
log.debug("finding all Game instances");
try {
String queryString = "from Game";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Game merge(Game detachedInstance) {
log.debug("merging Game instance");
try {
Game result = (Game) getHibernateTemplate().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Game instance) {
log.debug("attaching dirty Game instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Game instance) {
log.debug("attaching clean Game instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static GameDAO getFromApplicationContext(ApplicationContext ctx) {
return (GameDAO) ctx.getBean("GameDAO");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Hibernate+Spring实例代码,可以与Oracle数据库进行增删改查操作。
共91个文件
jar:65个
class:5个
java:5个
5星 · 超过95%的资源 需积分: 9 47 下载量 164 浏览量
2010-10-09
15:08:12
上传
评论
收藏 17.24MB RAR 举报
温馨提示
Hibernate+Spring实例代码,可以与Oracle数据库进行增删改查操作。
资源推荐
资源详情
资源评论
收起资源包目录
Hibernate+Spring实例代码,可以与Oracle数据库进行增删改查操作。 Hibernate&Spring.rar (91个子文件)
Spring&Hibernate
.project 2KB
.settings
.jsdtscope 500B
org.eclipse.jdt.core.prefs 334B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
.mymetadata 333B
WebRoot
WEB-INF
web.xml 365B
lib
connector.jar 18KB
commons-dbcp.jar 119KB
oscache-2.1.jar 112KB
commons-logging.jar 59KB
spring-aop.jar 318KB
jboss-cache.jar 505KB
log4j-1.2.11.jar 342KB
c3p0-0.9.1.jar 594KB
aopalliance.jar 4KB
hibernate-commons-annotations.jar 65KB
hibernate-annotations.jar 259KB
asm-commons-2.2.3.jar 15KB
asm-util-2.2.3.jar 34KB
cglib-nodep-2.1_3.jar 317KB
jta.jar 9KB
hibernate3.jar 2.15MB
asm-2.2.3.jar 34KB
log4j-1.2.15.jar 383KB
javassist.jar 460KB
commons-lang.jar 237KB
spring-tomcat-weaver.jar 9KB
jaxen-1.1-beta-7.jar 222KB
persistence.jar 69KB
commons-logging-1.0.4.jar 37KB
ehcache-1.2.3.jar 203KB
ojdbc14.jar 1.47MB
spring-context.jar 466KB
concurrent-1.3.2.jar 167KB
xml-apis.jar 121KB
jdbc2_0-stdext.jar 7KB
spring-tx.jar 226KB
aspectjlib.jar 8KB
spring-core.jar 279KB
commons-collections-2.1.1.jar 171KB
ejb3-persistence.jar 49KB
jboss-common.jar 570KB
jaas.jar 102KB
hibernate-entitymanager.jar 114KB
swarmcache-1.0rc2.jar 30KB
spring-beans.jar 477KB
commons-attributes-compiler.jar 29KB
c3p0-0.9.1.2.jar 596KB
dom4j-1.6.1.jar 307KB
proxool-0.8.3.jar 465KB
commons-attributes-api.jar 35KB
aspectjrt.jar 112KB
asm.jar 26KB
jacc-1_0-fr.jar 24KB
spring-agent.jar 5KB
jgroups-2.2.8.jar 1.54MB
hibernate-validator.jar 60KB
xerces-2.6.2.jar 987KB
jboss-system.jar 218KB
jboss-archive-browsing.jar 404KB
commons-pool.jar 61KB
cglib-2.1.3.jar 276KB
spring-jdbc.jar 328KB
jotm.jar 121KB
spring-orm.jar 369KB
antlr-2.7.6.jar 433KB
jboss-jmx.jar 578KB
asm-attrs.jar 16KB
spring-aspects.jar 20KB
xapool.jar 90KB
aspectjweaver.jar 1.47MB
classes
com
xmetc
xmu
test
TestSH.class 1KB
factory
HibernateSessionFactory.class 2KB
pojo
Game.class 461B
GameDAO.class 5KB
Game.hbm.xml 685B
AbstractGame.class 924B
applicationContext.xml 1KB
index.jsp 834B
META-INF
MANIFEST.MF 36B
.myeclipse
src
com
xmetc
xmu
test
TestSH.java 743B
factory
HibernateSessionFactory.java 3KB
pojo
Game.java 306B
AbstractGame.java 733B
Game.hbm.xml 685B
GameDAO.java 4KB
applicationContext.xml 1KB
.springBeans 469B
.classpath 5KB
.myhibernatedata 629B
共 91 条
- 1
资源评论
- 菜鸟先飞2014-08-06虽然没用到,但是大概看了下还是很不错的一个hibernate加spring实例
- dreamthink2015-01-14这个没有流程说明,比较难以理解。
zhengwh510
- 粉丝: 64
- 资源: 1981
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功