Package net.sf.hibernate

Examples of net.sf.hibernate.SessionFactory


    }

    protected String doInterceptInternal(ActionInvocation invocation) throws Exception {

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

        if (isSingleSession()) {
            if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
View Full Code Here


        assertEquals(rd.getDrillDownColumns().size(),0);
       
       
    }
    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

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

    }

    protected abstract ApplicationContext getContext();

    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

        super.tearDown();
        closeSession();
    }

    private void closeSession() {
        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
        SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
        SessionFactoryUtils.closeSessionIfNecessary(sessionHolder.getSession(), sessionFactory);
    }
View Full Code Here

  protected void doFilterInternal(
      HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
      throws ServletException, IOException {

    SessionFactory sessionFactory = lookupSessionFactory(request);
    boolean participate = false;

    if (isSingleSession()) {
      // single session mode
      if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
View Full Code Here

    SessionFactoryImplementor sessionFactoryImpl = null;
    if (sessionFactory instanceof SessionFactoryImplementor) {
      sessionFactoryImpl = ((SessionFactoryImplementor) sessionFactory);
    }
    else if (session != null) {
      SessionFactory internalFactory = session.getSessionFactory();
      if (internalFactory instanceof SessionFactoryImplementor) {
        sessionFactoryImpl = (SessionFactoryImplementor) internalFactory;
      }
    }
    return (sessionFactoryImpl != null ? sessionFactoryImpl.getTransactionManager() : null);
View Full Code Here

            // it doesn't exist, then we will create it, otherwise
            // we will use the one that already exists.
            session = (Session)request.getAttribute(SESSION_ATTRIBUTE_KEY);

            if (session == null) {
                SessionFactory sessionFactory = GlobalSessionFactory.get();
                if (useProxy) {
                    session = SessionProxy.createProxy(this, sessionFactory);
                } else {
                    session = sessionFactory.openSession();
                    if (log.isDebugEnabled()) {
                        log.debug("Session opened: "+session);
                    }
                }
                request.setAttribute(SESSION_ATTRIBUTE_KEY, session);
View Full Code Here

    private static Logger log = Logger.getLogger(HibernateHelper.class);

    public static void initializeHibernate() throws HibernateException {
        if (GlobalSessionFactory.get() == null) {
            Configuration cfg = initializeConfiguration();
            SessionFactory sessionFactory = cfg.buildSessionFactory();
            // XPlanner uses a custom session factory so that all sessions will be
            // automatically configured with an XPlanner-related Hibernate interceptor.
            GlobalSessionFactory.set(new XPlannerSessionFactory(sessionFactory));
        }
    }
View Full Code Here

        info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD);
        info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, "true");
        ProxoolFacade.registerConnectionPool(url, info);

        Configuration configuration = null;
        SessionFactory sessionFactory = null;
        Session session = null;
        Properties hibernateProperties = new Properties();
        Connection connection = null;

        try {
            hibernateProperties.setProperty(Environment.DRIVER, ProxoolDriver.class.getName());
            hibernateProperties.setProperty(Environment.URL, url);

            configuration = new Configuration().addProperties(hibernateProperties);

            // create a session object to the database
            sessionFactory = configuration.buildSessionFactory();
            session = sessionFactory.openSession();
            assertNotNull("Expected a session", session);

            // Inspect the assigned connection to the session from
            // the pool.
            connection = session.connection();
View Full Code Here

TOP

Related Classes of net.sf.hibernate.SessionFactory

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.