📄 bookbrowsehome.java
字号:
package library.hibernate;
// Generated 2006-8-5 16:17:23 by Hibernate Tools 3.1.0 beta3
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 static org.hibernate.criterion.Example.create;
/**
* Home object for domain model class BookBrowse.
* @see library.hibernate.BookBrowse
* @author Hibernate Tools
*/
public class BookBrowseHome {
private static final Log log = LogFactory.getLog(BookBrowseHome.class);
private final SessionFactory sessionFactory = getSessionFactory();
protected SessionFactory getSessionFactory() {
try {
return (SessionFactory) new InitialContext().lookup("SessionFactory");
}
catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException("Could not locate SessionFactory in JNDI");
}
}
public void persist(BookBrowse transientInstance) {
log.debug("persisting BookBrowse instance");
try {
sessionFactory.getCurrentSession().persist(transientInstance);
log.debug("persist successful");
}
catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void attachDirty(BookBrowse instance) {
log.debug("attaching dirty BookBrowse instance");
try {
sessionFactory.getCurrentSession().saveOrUpdate(instance);
log.debug("attach successful");
}
catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(BookBrowse instance) {
log.debug("attaching clean BookBrowse instance");
try {
sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
}
catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(BookBrowse persistentInstance) {
log.debug("deleting BookBrowse instance");
try {
sessionFactory.getCurrentSession().delete(persistentInstance);
log.debug("delete successful");
}
catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public BookBrowse merge(BookBrowse detachedInstance) {
log.debug("merging BookBrowse instance");
try {
BookBrowse result = (BookBrowse) sessionFactory.getCurrentSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
}
catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public BookBrowse findById( java.lang.String id) {
log.debug("getting BookBrowse instance with id: " + id);
try {
BookBrowse instance = (BookBrowse) sessionFactory.getCurrentSession()
.get("library.hibernate.BookBrowse", 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<BookBrowse> findByExample(BookBrowse instance) {
log.debug("finding BookBrowse instance by example");
try {
List<BookBrowse> results = (List<BookBrowse>) sessionFactory.getCurrentSession()
.createCriteria("library.hibernate.BookBrowse")
.add( 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;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -