package com.yongan.pojo;
// Generated 2004-4-7 9:36:34 by Hibernate Tools 3.2.0.b9
import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
import com.yongan.hibernate.BaseHome;
/**
* Home object for domain model class Name.
*
* @see com.yongan.pojo.Name
* @author Hibernate Tools
*/
public class NameHome extends BaseHome {
private static final Log log = LogFactory.getLog(NameHome.class);
public void persist(Name transientInstance) {
log.debug("persisting Name instance");
try {
currentSession().persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void attachDirty(Name instance) {
log.debug("attaching dirty Name instance");
try {
currentSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Name instance) {
log.debug("attaching clean Name instance");
try {
currentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(Name persistentInstance) {
log.debug("deleting Name instance");
try {
currentSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Name merge(Name detachedInstance) {
log.debug("merging Name instance");
try {
Name result = (Name) currentSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public Name findById(int id) {
log.debug("getting Name instance with id: " + id);
try {
Name instance = (Name) currentSession().get("com.yongan.pojo.Name",
id);
if (instance == null) {
log.debug("get successful, no instance found");
} else {
log.debug("get successful, instance found");
}
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Name instance) {
log.debug("finding Name instance by example");
try {
List results = currentSession().createCriteria(
"com.yongan.pojo.Name").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 findByAll(int firstResult, int maxResult) {
Query query = currentSession().createQuery("from Name");
query.setFirstResult(firstResult);// 记录开始的位置
query.setMaxResults(maxResult);// 记录显示的条数
return query.list();
}
public List findByAll() {
Query query = currentSession().createQuery("from Name");
return query.list();
}
/*
* 返回所有的记录
*/
public int getResult() {
Query query = currentSession().createQuery("from Name");
return query.list().size();
}
public static void main(String[] args) {
System.out.print(new NameHome().getResult());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
hibernateDemo
共42个文件
xml:11个
jar:11个
java:6个
需积分: 0 14 下载量 38 浏览量
2008-07-02
11:03:59
上传
评论
收藏 3.74MB RAR 举报
温馨提示
这是hibernate+Mysql的
资源推荐
资源详情
资源评论
收起资源包目录
HibernateDemo.rar (42个子文件)
HibernateDemo
.project 1KB
.settings
org.eclipse.wst.common.component 414B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.common.project.facet.core.xml 229B
org.eclipse.jst.common.project.facet.core.prefs 217B
org.hibernate.eclipse.console.prefs 124B
src
com
cost
persistence
hibernate
pojo
yongan
set
pojo
Student.hbm.xml 1KB
Classes.hbm.xml 985B
Classes.java 999B
StudentHome.java 3KB
ClassesHome.java 3KB
Student.java 1KB
pojo
Name.hbm.xml 873B
NameHome.java 4KB
Name.java 820B
hibernate.cfg.xml 877B
hibernate.reveng.xml 348B
build
classes
com
cost
persistence
hibernate
pojo
yongan
set
pojo
Student.hbm.xml 1KB
Classes.hbm.xml 985B
ClassesHome.class 5KB
StudentHome.class 4KB
Classes.class 1KB
Student.class 1KB
pojo
Name.class 1KB
Name.hbm.xml 873B
NameHome.class 5KB
hibernate.cfg.xml 877B
WebContent
WEB-INF
web.xml 640B
lib
jta.jar 9KB
hibernate3.jar 2.1MB
commons-logging-1.0.4.jar 37KB
mysql-connector-java-5.0.3-bin.jar 482KB
commons-collections-2.1.1.jar 171KB
util.jar 15KB
dom4j-1.6.1.jar 307KB
asm.jar 26KB
log4j.jar 344KB
cglib-2.1.3.jar 276KB
antlr-2.7.2.jar 350KB
META-INF
MANIFEST.MF 39B
nameList.jsp 2KB
.classpath 548B
共 42 条
- 1
资源评论
wangqingbo1225
- 粉丝: 2
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功