⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usertablehome.java

📁 是Eclipse web开发从入门到精通的源码
💻 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 UserTable.
 * @see library.hibernate.UserTable
 * @author Hibernate Tools
 */
public class UserTableHome {

    private static final Log log = LogFactory.getLog(UserTableHome.class);

    private final SessionFactory sessionFactory = getSessionFactory();
    
    public 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(UserTable transientInstance) {
        log.debug("persisting UserTable instance");
        try {
            sessionFactory.getCurrentSession().persist(transientInstance);
            log.debug("persist successful");
        }
        catch (RuntimeException re) {
            log.error("persist failed", re);
            throw re;
        }
    }
    
    public void attachDirty(UserTable instance) {
        log.debug("attaching dirty UserTable instance");
        try {
            sessionFactory.getCurrentSession().saveOrUpdate(instance);
            log.debug("attach successful");
        }
        catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(UserTable instance) {
        log.debug("attaching clean UserTable 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(UserTable persistentInstance) {
        log.debug("deleting UserTable instance");
        try {
            sessionFactory.getCurrentSession().delete(persistentInstance);
            log.debug("delete successful");
        }
        catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public UserTable merge(UserTable detachedInstance) {
        log.debug("merging UserTable instance");
        try {
            UserTable result = (UserTable) sessionFactory.getCurrentSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        }
        catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }
    
    public UserTable findById( java.lang.String id) {
        log.debug("getting UserTable instance with id: " + id);
        try {
            UserTable instance = (UserTable) sessionFactory.getCurrentSession()
                    .get("library.hibernate.UserTable", 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<UserTable> findByExample(UserTable instance) {
        log.debug("finding UserTable instance by example");
        try {
            List<UserTable> results = (List<UserTable>) sessionFactory.getCurrentSession()
                    .createCriteria("library.hibernate.UserTable")
                    .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 + -