Package org.hibernate

Examples of org.hibernate.SessionFactory


      config.add(createBaseNamedElement(Environment.TRANSACTION_MANAGER_STRATEGY, TransactionManagerLookupImpl.class.getName()));
      config.add(createBaseNamedElement(Environment.USER_TRANSACTION, JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME));
      testee.setConfigurationElements(config);
      testee.start();
     
      SessionFactory factory = testee.getInstance();
      assertTrue(factory instanceof SessionFactoryImplementor);
      Settings settings = ((SessionFactoryImplementor) factory).getSettings();
      assertTrue(settings.getTransactionFactory() instanceof JTATransactionFactory);
      assertTrue(settings.isSecondLevelCacheEnabled());
     
View Full Code Here


      assertTrue(testee.isScanForMappingsEnabled());
      assertEquals(MockInterceptor.class.getName(), testee.getSessionFactoryInterceptor());
      assertEquals(MockListenerInjector.class.getName(), testee.getListenerInjector());
     
      // Where we can, validate stuff exposed by hibernate Settings
      SessionFactory factory = testee.getInstance();
      assertTrue(factory instanceof SessionFactoryImplementor);
      Settings settings = ((SessionFactoryImplementor) factory).getSettings();
     
//      assertEquals(TestableHibernate.class.getSimpleName() + testCount, settings.getSessionFactoryName());
      assertEquals(HSQLDialect.class.getName(), testee.getDialect());
View Full Code Here

    return parameters;
  }

  private static Session createSession()
  {
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
   
    return sessionFactory.openSession();
  }
View Full Code Here

        // Initialize the Hibernate session factory.
        ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(hbmConfig.getProperties());
        ServiceRegistry serviceRegistry = (ServiceRegistry) ReflectionUtils.invokeMethod(serviceRegistryBuilder, "buildServiceRegistry", null);
        if (serviceRegistry == null) serviceRegistry = (ServiceRegistry) ReflectionUtils.invokeMethod(serviceRegistryBuilder, "build", null);
        SessionFactory factory = hbmConfig.buildSessionFactory(serviceRegistry);
        hibernateSessionFactoryProvider.setSessionFactory(factory);

        // Set the default schema if specified via system property or via hibernate configuration.
        // NOTE: To set the default schema via hibernate configuration, the hibernate.cfg.xml file must be modified.
        //       This file is located inside the generated webapp. So, if the user wants to change the working schema,
View Full Code Here

   */
  private void tryBoot(String configurationResourceName) {
    Configuration cfg = new OgmConfiguration();
    cfg.setProperty( OgmProperties.DATASTORE_PROVIDER, "infinispan" );
    cfg.setProperty( InfinispanProperties.CONFIGURATION_RESOURCE_NAME, configurationResourceName );
    SessionFactory sessionFactory = cfg.buildSessionFactory();
    if ( sessionFactory != null ) {
      try {
        // trigger service initialization, and also verifies it actually uses Infinispan:
        InfinispanTestHelper.getProvider( sessionFactory );
      }
      finally {
        sessionFactory.close();
      }
    }
  }
View Full Code Here

      {
         sessionFactory_ = SecurityHelper.doPrivilegedAction(new PrivilegedAction<SessionFactory>()
         {
            public SessionFactory run()
            {
               SessionFactory factory = conf_.buildSessionFactory();
               new SchemaUpdate(conf_).execute(false, true);
               return factory;
            }
         });
      }
View Full Code Here

                                }
                            }
                        }

                        ServiceRegistry serviceRegistryBuilder = new StandardServiceRegistryBuilder().applySettings(hibernateConfiguration.getProperties()).build();
                        SessionFactory sessionFactory = hibernateConfiguration.buildSessionFactory(serviceRegistryBuilder);
                        return new HibernateSessionManager(sessionFactory);
                    }
                })
                .in(Scopes.SINGLETON);
    }
View Full Code Here

   
    if (configuration==null) {
      throw new WireException("couldn't find configuration");
    }
   
    SessionFactory sessionFactory = configuration.buildSessionFactory();
   
    wireContext.addListener(new SessionFactoryCloser(sessionFactory));

    return sessionFactory;
  }
View Full Code Here

  protected String standardTransactionName;
  protected String connectionName;

  public Object construct(WireContext wireContext) {
    // get the hibernate-session-factory
    SessionFactory sessionFactory = null;
    if (factoryName!=null) {
      sessionFactory = (SessionFactory) wireContext.get(factoryName);
    } else {
      Environment environment = wireContext.getEnvironment();
      if (environment!=null) {
        sessionFactory = environment.get(SessionFactory.class);
      } else {
        sessionFactory = wireContext.get(SessionFactory.class);
      }
    }
    if (sessionFactory==null) {
      throw new WireException("couldn't find hibernate-session-factory "+(factoryName!=null ? "'"+factoryName+"'" : "by type ")+"to open a hibernate-session");
    }

    // open the hibernate-session
    Session session = null;
    if (connectionName!=null) {
      Connection connection = (Connection) wireContext.get(connectionName);
      log.finest("creating hibernate session with connection "+connection);
      session = sessionFactory.openSession(connection);

    } else {
      log.finest("creating hibernate session");
      session = sessionFactory.openSession();
    }

    return session;
  }
View Full Code Here

  public boolean matches(String name, Object value) {
    boolean matches = false;
   
    Environment environment = Environment.getCurrent();
    if (environment!=null) {
      SessionFactory sessionFactory = (SessionFactory) environment.get("hibernate.session.factory");
      if (sessionFactory!=null) {
        ClassMetadata classMetadata = sessionFactory.getClassMetadata(value.getClass());
        matches = ( (classMetadata!=null)
                    && (classMetadata.getIdentifierType().getClass()==StringType.class)
                   );
      }
    } else {
View Full Code Here

TOP

Related Classes of org.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.