Package org.hibernate.service.spi

Examples of org.hibernate.service.spi.ServiceRegistryImplementor


  }

  private static InfinispanDatastoreProvider createAndStartNewProvider() {
    Map<String, Object> configurationValues = new HashMap<String, Object>();
    configurationValues.put( InfinispanProperties.CONFIGURATION_RESOURCE_NAME, "infinispan-dist-duplicate-domains-allowed.xml" );
    ServiceRegistryImplementor serviceRegistry = getServiceRegistry();

    InfinispanDatastoreProvider provider = new InfinispanDatastoreProvider();
    provider.configure( configurationValues );
    provider.injectServices( serviceRegistry );
    provider.start();
View Full Code Here


    return provider;
  }

  private static ServiceRegistryImplementor getServiceRegistry() {
    ServiceRegistryImplementor serviceRegistry = mock( ServiceRegistryImplementor.class );
    JBossStandAloneJtaPlatform jtaPlatform = new JBossStandAloneJtaPlatform();
    jtaPlatform.injectServices( serviceRegistry );

    when( serviceRegistry.getService( ClassLoaderService.class ) ).thenReturn( new ClassLoaderServiceImpl() );
    when( serviceRegistry.getService( JtaPlatform.class ) ).thenReturn( jtaPlatform );

    return serviceRegistry;
  }
View Full Code Here

    dbLocation = Neo4jTestHelper.dbLocation();
    Properties configurationValues = new Properties();
    configurationValues.put( Neo4jProperties.DATABASE_PATH, dbLocation );
    provider = new Neo4jDatastoreProvider();

    ServiceRegistryImplementor serviceRegistry = mock( ServiceRegistryImplementor.class );
    when( serviceRegistry.getService( ClassLoaderService.class ) ).thenReturn( new ClassLoaderServiceImpl() );
    provider.injectServices( serviceRegistry );

    Set<PersistentNoSqlIdentifierGenerator> sequences = new HashSet<PersistentNoSqlIdentifierGenerator>();
    sequences.add( identifierGenerator( INITIAL_VALUE_SEQUENCE, INITIAL_VALUE_FIRST_VALUE_TEST ) );
    sequences.add( identifierGenerator( THREAD_SAFETY_SEQUENCE, INITIAL_VALUE_THREAD_SAFETY_TEST ) );
View Full Code Here

      fail( "The expected exception has not been raised, a MongoDB instance runs on " + NON_EXISTENT_IP );
    }
  }

  private ServiceRegistryImplementor getServiceRegistry(Map<String, ?> cfg) {
    ServiceRegistryImplementor serviceRegistry = mock( ServiceRegistryImplementor.class );
    when( serviceRegistry.getService( ClassLoaderService.class ) ).thenReturn( new ClassLoaderServiceImpl() );

    OptionsServiceImpl optionsService = new OptionsServiceImpl();
    optionsService.injectServices( serviceRegistry );
    optionsService.configure( cfg );
    when( serviceRegistry.getService( OptionsService.class ) ).thenReturn( optionsService );

    return serviceRegistry;
  }
View Full Code Here

    return getService( GridDialect.class ).getTuple( key, tupleContext );
  }

  protected <S extends Service> S getService(Class<S> serviceRole) {
    SessionFactoryImplementor factory = super.sfi();
    ServiceRegistryImplementor serviceRegistry = factory.getServiceRegistry();
    return serviceRegistry.getService( serviceRole );
  }
View Full Code Here

  private static final Log log = LoggerFactory.getLogger();

  @Override
  public void initializeSchema(Configuration configuration, SessionFactoryImplementor factory) {
    SessionFactoryImplementor sessionFactoryImplementor = factory;
    ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry();
    Neo4jDatastoreProvider provider = (Neo4jDatastoreProvider) registry.getService( DatastoreProvider.class );

    createSequences( sessionFactoryImplementor, provider );
    createEntityConstraints( provider.getDataBase(), configuration );
  }
View Full Code Here

  }

  @Override
  public void sessionFactoryCreated(SessionFactory factory) {
    SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) factory;
    ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry();

    SchemaDefiner schemaInitializer = registry.getService( SchemaDefiner.class );
    schemaInitializer.validateMapping( sessionFactoryImplementor );
    schemaInitializer.initializeSchema( configuration, sessionFactoryImplementor );
  }
View Full Code Here

    super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory );
    if ( log.isTraceEnabled() ) {
      log.tracef( "Creating OgmEntityPersister for %s", persistentClass.getClassName() );
    }

    ServiceRegistryImplementor serviceRegistry = factory.getServiceRegistry();
    this.gridDialect = serviceRegistry.getService( GridDialect.class );
    this.identityColumnAwareGridDialect = serviceRegistry.getService( IdentityColumnAwareGridDialect.class );
    this.optimisticLockingAwareGridDialect = serviceRegistry.getService( OptimisticLockingAwareGridDialect.class );
    this.optionsService = serviceRegistry.getService( OptionsService.class );

    if ( factory.getIdentifierGenerator( getEntityName() ) instanceof OgmIdentityGenerator && identityColumnAwareGridDialect == null ) {
      throw log.getIdentityGenerationStrategyNotSupportedException( getEntityName() );
    }

    tableName = persistentClass.getTable().getQualifiedName(
        factory.getDialect(),
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
    );

    this.discriminator = discriminator;

    //SPACES
    //TODO: i'm not sure, but perhaps we should exclude
    //      abstract denormalized tables?

    int spacesSize = 1 + persistentClass.getSynchronizedTables().size();
    spaces = new String[spacesSize];
    spaces[0] = tableName;
    @SuppressWarnings( "unchecked" )
    Iterator<String> syncTablesIter = persistentClass.getSynchronizedTables().iterator();
    for ( int i = 1; i < spacesSize; i++ ) {
      spaces[i] = syncTablesIter.next();
    }

    HashSet<String> subclassTables = new HashSet<String>();
    Iterator<Table> tableIter = persistentClass.getSubclassTableClosureIterator();
    while ( tableIter.hasNext() ) {
      Table table = tableIter.next();
      subclassTables.add( table.getQualifiedName(
          factory.getDialect(),
          factory.getSettings().getDefaultCatalogName(),
          factory.getSettings().getDefaultSchemaName()
      ) );
    }
    subclassSpaces = ArrayHelper.toStringArray( subclassTables );

    if ( isMultiTable() ) {
      int idColumnSpan = getIdentifierColumnSpan();
      ArrayList<String> tableNames = new ArrayList<String>();
      ArrayList<String[]> keyColumns = new ArrayList<String[]>();
      if ( !isAbstract() ) {
        tableNames.add( tableName );
        keyColumns.add( getIdentifierColumnNames() );
      }
      @SuppressWarnings( "unchecked" )
      Iterator<Table> iter = persistentClass.getSubclassTableClosureIterator();
      while ( iter.hasNext() ) {
        Table tab = iter.next();
        if ( !tab.isAbstractUnionTable() ) {
          String tableName = tab.getQualifiedName(
              factory.getDialect(),
              factory.getSettings().getDefaultCatalogName(),
              factory.getSettings().getDefaultSchemaName()
          );
          tableNames.add( tableName );
          String[] key = new String[idColumnSpan];

          Iterator<Column> citer = tab.getPrimaryKey().getColumnIterator();
          for ( int k = 0; k < idColumnSpan; k++ ) {
            key[k] = citer.next().getQuotedName( factory.getDialect() );
          }
          keyColumns.add( key );
        }
      }

      constraintOrderedTableNames = ArrayHelper.toStringArray( tableNames );
      constraintOrderedKeyColumnNames = ArrayHelper.to2DStringArray( keyColumns );
    }
    else {
      constraintOrderedTableNames = new String[] { tableName };
      constraintOrderedKeyColumnNames = new String[][] { getIdentifierColumnNames() };
    }

    initPropertyPaths( mapping );

    //Grid related metadata
    TypeTranslator typeTranslator = serviceRegistry.getService( TypeTranslator.class );
    final Type[] types = getPropertyTypes();
    final int length = types.length;
    gridPropertyTypes = new GridType[length];
    for (int index = 0 ; index < length ; index++) {
      gridPropertyTypes[index] = typeTranslator.getType( types[index] );
View Full Code Here

    return tuple.get( columnName );
  }

  private void defineGridTypes(SessionImplementor session) {
    if ( identifierValueGridType == null ) {
      ServiceRegistryImplementor registry = session.getFactory().getServiceRegistry();
      identifierValueGridType = registry.getService( TypeTranslator.class ).getType( new LongType() );
    }
  }
View Full Code Here

      final EntityDiscriminator discriminator) throws HibernateException {
    super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory );
    if ( log.isTraceEnabled() ) {
      log.tracef( "Creating OgmEntityPersister for %s", persistentClass.getClassName() );
    }
    ServiceRegistryImplementor serviceRegistry = factory.getServiceRegistry();
    this.gridDialect = serviceRegistry.getService( GridDialect.class );
    this.optionsService = serviceRegistry.getService( OptionsService.class );

    tableName = persistentClass.getTable().getQualifiedName(
        factory.getDialect(),
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
    );

    this.discriminator = discriminator;

    //SPACES
    //TODO: i'm not sure, but perhaps we should exclude
    //      abstract denormalized tables?

    int spacesSize = 1 + persistentClass.getSynchronizedTables().size();
    spaces = new String[spacesSize];
    spaces[0] = tableName;
    @SuppressWarnings( "unchecked" )
    Iterator<String> syncTablesIter = persistentClass.getSynchronizedTables().iterator();
    for ( int i = 1; i < spacesSize; i++ ) {
      spaces[i] = syncTablesIter.next();
    }

    HashSet<String> subclassTables = new HashSet<String>();
    Iterator<Table> tableIter = persistentClass.getSubclassTableClosureIterator();
    while ( tableIter.hasNext() ) {
      Table table = tableIter.next();
      subclassTables.add( table.getQualifiedName(
          factory.getDialect(),
          factory.getSettings().getDefaultCatalogName(),
          factory.getSettings().getDefaultSchemaName()
      ) );
    }
    subclassSpaces = ArrayHelper.toStringArray( subclassTables );

    if ( isMultiTable() ) {
      int idColumnSpan = getIdentifierColumnSpan();
      ArrayList<String> tableNames = new ArrayList<String>();
      ArrayList<String[]> keyColumns = new ArrayList<String[]>();
      if ( !isAbstract() ) {
        tableNames.add( tableName );
        keyColumns.add( getIdentifierColumnNames() );
      }
      @SuppressWarnings( "unchecked" )
      Iterator<Table> iter = persistentClass.getSubclassTableClosureIterator();
      while ( iter.hasNext() ) {
        Table tab = iter.next();
        if ( !tab.isAbstractUnionTable() ) {
          String tableName = tab.getQualifiedName(
              factory.getDialect(),
              factory.getSettings().getDefaultCatalogName(),
              factory.getSettings().getDefaultSchemaName()
          );
          tableNames.add( tableName );
          String[] key = new String[idColumnSpan];
          @SuppressWarnings( "unchecked" )
          Iterator<Column> citer = tab.getPrimaryKey().getColumnIterator();
          for ( int k = 0; k < idColumnSpan; k++ ) {
            key[k] = citer.next().getQuotedName( factory.getDialect() );
          }
          keyColumns.add( key );
        }
      }

      constraintOrderedTableNames = ArrayHelper.toStringArray( tableNames );
      constraintOrderedKeyColumnNames = ArrayHelper.to2DStringArray( keyColumns );
    }
    else {
      constraintOrderedTableNames = new String[] { tableName };
      constraintOrderedKeyColumnNames = new String[][] { getIdentifierColumnNames() };
    }

    initPropertyPaths( mapping );

    //Grid related metadata
    TypeTranslator typeTranslator = serviceRegistry.getService( TypeTranslator.class );
    final Type[] types = getPropertyTypes();
    final int length = types.length;
    gridPropertyTypes = new GridType[length];
    for (int index = 0 ; index < length ; index++) {
      gridPropertyTypes[index] = typeTranslator.getType( types[index] );
View Full Code Here

TOP

Related Classes of org.hibernate.service.spi.ServiceRegistryImplementor

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.