📄 40043feae70c001d137bd969311cc581
字号:
package com.lib.persistence.hibernate.home;
// Generated 2008-4-18 9:10:33 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.SessionFactory;
import org.hibernate.criterion.Example;
import com.lib.persistence.hibernate.home.BaseHome;
import com.lib.persistence.pojo.Book;
/**
* Home object for domain model class Book.
* @see com.lib.persistence.pojo.Book
* @author Hibernate Tools
*/
public class BookHome extends BaseHome{
private static final Log log = LogFactory.getLog(BookHome.class);
private static BookHome instance;
public static BookHome getInstance(){
if(instance==null){
instance = new BookHome();
}
return instance;
}
public void persist(Book transientInstance) {
log.debug("persisting Book instance");
try {
currentSession().persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void attachDirty(Book instance) {
log.debug("attaching dirty Book instance");
try {
currentSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Book instance) {
log.debug("attaching clean Book instance");
try {
currentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(Book persistentInstance) {
log.debug("deleting Book instance");
try {
currentSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Book merge(Book detachedInstance) {
log.debug("merging Book instance");
try {
Book result = (Book) currentSession().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public Book findById(int id) {
log.debug("getting Book instance with id: " + id);
try {
Book instance = (Book) currentSession().get(
"com.lib.persistence.pojo.Book", new Integer(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(Book instance) {
log.debug("finding Book instance by example");
try {
List results = currentSession().createCriteria(
"com.lib.persistence.pojo.Book").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 findAllBook(){
List list = currentSession().createQuery("from Book").list();
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -