Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration.buildSessionFactory()


    config.setProperty( "hibernate.search.lucene_version", TestConstants.getTargetLuceneVersion().toString() );
    config.setProperty( "hibernate.search.default.directory_provider", "ram" );
    config.setProperty( "hibernate.search.default.indexBase", TestConstants.getIndexDirectory( TokenizationTest.class ) );

    config.buildSessionFactory();

    assertEquals( "Wrong invocation count", 1, BytemanHelper.getAndResetInvocationCount() );
  }

  @Entity
View Full Code Here


    ServiceRegistryBuilder registryBuilder = new ServiceRegistryBuilder();
    registryBuilder.applySettings( hibernateConfiguration.getProperties() );

    ServiceRegistry serviceRegistry = ServiceRegistryTools.build( registryBuilder );
    try {
      hibernateConfiguration.buildSessionFactory( serviceRegistry );
      fail( "ByteMan should have forced an exception" );
    }
    catch (RuntimeException e) {
      assertEquals( "Wrong invocation count", 1, BytemanHelper.getAndResetInvocationCount() );
    }
View Full Code Here

    File sub = getBaseIndexDir();
    config.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );

    config.addAnnotatedClass( Animal.class );

    SessionFactory newSessionFactory = config.buildSessionFactory();
    FullTextSession fullTextSession = Search.getFullTextSession( newSessionFactory.openSession() );
    return (SearchFactoryImplementor) fullTextSession.getSearchFactory();
  }

  public static class AnimalShardIdentifierProvider extends ShardIdentifierProviderTemplate {
View Full Code Here

    Configuration config = new Configuration();
    config.addAnnotatedClass( SnowStorm.class );
    config.setProperty( "hibernate.search.default.indexBase", getBaseIndexDir().getAbsolutePath() );
    config.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
    config.setProperty( "hibernate.search.default.filesystem_access_type", directoryType );
    return config.buildSessionFactory();
  }

  @Override
  protected Class<?>[] getAnnotatedClasses() {
    return new Class[] { };
View Full Code Here

    for ( int i = 0; i < getAnnotatedClasses().length; i++ ) {
      cfg.addAnnotatedClass( getAnnotatedClasses()[i] );
    }
    cfg.setProperty( "hibernate.search.default.directory_provider", "ram" );
    try {
      cfg.buildSessionFactory();
      fail( "Undefined bridge went through" );
    }
    catch (Exception e) {
      Throwable ee = e;
      boolean hasSearchException = false;
View Full Code Here

  private SessionFactory getSessionFactory() {
    Configuration cfg = new Configuration();
    cfg.addAnnotatedClass( Author.class );
    cfg.addAnnotatedClass( Book.class );
    cfg.addProperties( getHibernateProperties() );
    return cfg.buildSessionFactory();
  }

  private Properties getHibernateProperties() {
    Properties properties = scenario.getHibernateProperties();
    setDefaultProperty( properties, "hibernate.dialect", "org.hibernate.dialect.H2Dialect" );
View Full Code Here

    Configuration config = new Configuration();
    config.addAnnotatedClass( Entity1.class );
    config.addAnnotatedClass( Entity2.class );
    config.setProperty( "hibernate.search.default.directory_provider", "ram" );
    try {
      config.buildSessionFactory();
      fail( "Session creation should have failed due to duplicate analyzer definition" );
    }
    catch (SearchException e) {
      assertTrue(
          "Multiple analyzer definitions with the same name: my-analyzer"
View Full Code Here

  public void testDuplicatedProgrammaticAnalyzerDefinitionThrowsException() throws Exception {
    Configuration config = new Configuration();
    config.getProperties().put( Environment.MODEL_MAPPING, createSearchMapping() );
    config.setProperty( "hibernate.search.default.directory_provider", "ram" );
    try {
      config.buildSessionFactory();
      fail( "Session creation should have failed due to duplicate analyzer definition" );
    }
    catch (SearchException e) {
      assertTrue(
          "Multiple analyzer definitions with the same name: english"
View Full Code Here

    ServiceRegistryBuilder registryBuilder = new ServiceRegistryBuilder();
    registryBuilder.applySettings( hibConfiguration.getProperties() );

    final ServiceRegistry serviceRegistry = ServiceRegistryTools.build( registryBuilder );
    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) hibConfiguration.buildSessionFactory(
        serviceRegistry
    );
    ServiceRegistryImplementor serviceRegistryImplementor = sessionFactoryImpl.getServiceRegistry();
    EventListenerRegistry registry = serviceRegistryImplementor.getService( EventListenerRegistry.class );
View Full Code Here

        "hibernate.search.default.retry_marker_lookup", String.valueOf( retries )
    );
    cfg.addAnnotatedClass( SnowStorm.class );
    long start = System.nanoTime();
    try {
      cfg.buildSessionFactory();
    }
    catch (SearchException e) {
      final long elapsedTime = TimeUnit.NANOSECONDS.toSeconds( System.nanoTime() - start );
      assertTrue( "Should be around 10 seconds: " + elapsedTime, elapsedTime > retries * 5 - 1 ); // -1 for safety
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.