package hibernateConfig;
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;
/**
* Data access object (DAO) for domain model class CourseBasicInfo.
*
* @see hibernateConfig.CourseBasicInfo
* @author MyEclipse Persistence Tools
*/
public class CourseBasicInfoDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(CourseBasicInfoDAO.class);
// property constants
public static final String COURSE_NAME = "courseName";
public static final String DESCRIPTION = "description";
public void save(CourseBasicInfo transientInstance) {
log.debug("saving CourseBasicInfo instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(CourseBasicInfo persistentInstance) {
log.debug("deleting CourseBasicInfo instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public CourseBasicInfo findById(java.lang.Integer id) {
log.debug("getting CourseBasicInfo instance with id: " + id);
try {
CourseBasicInfo instance = (CourseBasicInfo) getSession().get(
"hibernateConfig.CourseBasicInfo", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(CourseBasicInfo instance) {
log.debug("finding CourseBasicInfo instance by example");
try {
List results = getSession().createCriteria(
"hibernateConfig.CourseBasicInfo").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 CourseBasicInfo instance with property: "
+ propertyName + ", value: " + value);
try {
String queryString = "from CourseBasicInfo 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 findByCourseName(Object courseName) {
return findByProperty(COURSE_NAME, courseName);
}
public List findByDescription(Object description) {
return findByProperty(DESCRIPTION, description);
}
public List findAll() {
log.debug("finding all CourseBasicInfo instances");
try {
String queryString = "from CourseBasicInfo";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public CourseBasicInfo merge(CourseBasicInfo detachedInstance) {
log.debug("merging CourseBasicInfo instance");
try {
CourseBasicInfo result = (CourseBasicInfo) getSession().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(CourseBasicInfo instance) {
log.debug("attaching dirty CourseBasicInfo instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(CourseBasicInfo instance) {
log.debug("attaching clean CourseBasicInfo instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Hibernate 显示数据库数据
共57个文件
java:19个
class:19个
xml:12个
需积分: 10 10 下载量 9 浏览量
2012-03-22
10:06:13
上传
评论
收藏 785KB ZIP 举报
温馨提示
适合初学者使用。使用Hibernate做查询数据库,代码为eclipse项目,直接导入即可使用,只供参考。
资源推荐
资源详情
资源评论
收起资源包目录
HibernateShowStudent.zip (57个子文件)
HibernateShowStudent
.project 1KB
.mymetadata 333B
src
hibernate.cfg.xml 1KB
test
GetDiplomaInfo.java 640B
GetStudentInfo.java 660B
hibernateConfig
StuRelationCourseId.java 744B
CourseBasicInfo.java 668B
StuBasicInfoDAO.java 4KB
DiplomaInfo.hbm.xml 858B
CourseBasicInfoDAO.java 4KB
DiplomaInfo.java 598B
StuRelationCourse.hbm.xml 1KB
StuRelationCourseDAO.java 4KB
DiplomaInfoDAO.java 4KB
IBaseHibernateDAO.java 226B
AbstractCourseBasicInfo.java 2KB
BaseHibernateDAO.java 312B
StuBasicInfo.hbm.xml 1KB
HibernateSessionFactory.java 3KB
StuBasicInfo.java 652B
StuRelationCourse.java 536B
AbstractStuBasicInfo.java 2KB
AbstractStuRelationCourseId.java 3KB
AbstractStuRelationCourse.java 1KB
AbstractDiplomaInfo.java 1KB
CourseBasicInfo.hbm.xml 1KB
WebRoot
WEB-INF
classes
hibernate.cfg.xml 1KB
test
GetStudentInfo.class 1KB
GetDiplomaInfo.class 2KB
hibernateConfig
AbstractStuBasicInfo.class 2KB
DiplomaInfo.hbm.xml 858B
AbstractStuRelationCourseId.class 2KB
StuRelationCourse.hbm.xml 1KB
AbstractStuRelationCourse.class 1KB
IBaseHibernateDAO.class 180B
CourseBasicInfo.class 784B
DiplomaInfoDAO.class 5KB
StuRelationCourseDAO.class 5KB
StuRelationCourseId.class 866B
AbstractCourseBasicInfo.class 2KB
CourseBasicInfoDAO.class 5KB
StuRelationCourse.class 726B
StuBasicInfo.hbm.xml 1KB
AbstractDiplomaInfo.class 1KB
HibernateSessionFactory.class 2KB
BaseHibernateDAO.class 502B
StuBasicInfo.class 779B
DiplomaInfo.class 784B
StuBasicInfoDAO.class 5KB
CourseBasicInfo.hbm.xml 1KB
lib
mysql-connector-java-5.1.17-bin.jar 769KB
web.xml 375B
index.jsp 829B
META-INF
MANIFEST.MF 39B
.myeclipse
.myhibernatedata 562B
hibernate.reveng.xml 342B
.classpath 541B
共 57 条
- 1
资源评论
guan825
- 粉丝: 2
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功