Package net.sf.hibernate

Examples of net.sf.hibernate.Session


    protected String doInterceptInternal(ActionInvocation invocation) throws Exception {

        String result = "";
        SessionFactory sessionFactory = lookupSessionFactory();
        Session session = null;
        boolean participate = false;

        if (isSingleSession()) {
            if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
                participate = true;
View Full Code Here


        return (SessionFactory) wac.getBean(getSessionFactoryBeanName());
    }

    protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
        Session session = SessionFactoryUtils.getSession(sessionFactory, true);
        session.setFlushMode(FlushMode.NEVER);
        return session;
    }
View Full Code Here

        conn.close();
        return rs;
    }

    private Connection getConnection() throws HibernateException {
        Session session = _factory.openSession();
        return session.connection();
    }
View Full Code Here

        doPersistAction(warning, SAVE_OPERATION);
    }

    private void doPersistAction(Object obj, int operation) throws YPersistenceException {
        try {
            Session session = _factory.openSession();
            Transaction tx = session.beginTransaction();
            if (UPDATE_OPERATION == operation) {
                session.update(obj);
            } else if (DELETE_OPERATION == operation) {
                session.delete(obj);
            } else if (SAVE_OPERATION == operation) {
                session.save(obj);
            }
            session.flush();
            session.evict(obj);
            tx.commit();
            session.close();
        } catch (HibernateException e) {
            throw new YPersistenceException("Hibernate problem: " + e.getMessage(), e);
        }
    }
View Full Code Here

    }

    public static final ThreadLocal session = new ThreadLocal();

    public static Session currentSession() throws HibernateException {
        Session s = (Session) session.get();
        // Open a new Session, if this Thread has none yet
        if (s == null) {
            s = sessionFactory.openSession();
            session.set(s);
        }
View Full Code Here

        }
        return s;
    }

    public static void closeSession() throws HibernateException {
        Session s = (Session) session.get();
        session.set(null);
        if (s != null)
            s.close();
    }
View Full Code Here

        // cast to the types I want to use
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;
        HttpSession session = request.getSession(true);

        Session ses = null;
        boolean sessionCreated = false;

        try
        {
            chain.doFilter(request, response);
View Full Code Here

    //~ Methods ================================================================

    public static Session currentSession() throws PersistenceException
    {
        Session s = (Session) session.get();

        if (s == null)
        {
            s = PersistenceManager.openSession();
            if (log.isDebugEnabled())
View Full Code Here

        return s;
    }

    public static void closeSession() throws HibernateException, JDBCException
    {
        Session s = (Session) session.get();
        session.set(null);

        if (s != null)
        {
            if (s.isOpen())
            {
                s.flush();
                s.close();

                if (log.isDebugEnabled())
                {
                    log.debug("Closed hibernate session.");
                }
View Full Code Here

       
       
    }
    private void openSession() {
        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
        Session hibSession = SessionFactoryUtils.getSession(sessionFactory, true);
        hibSession.setFlushMode(FlushMode.NEVER);
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(hibSession));
    }
View Full Code Here

TOP

Related Classes of net.sf.hibernate.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.