Package org.hibernate.service.spi

Examples of org.hibernate.service.spi.ServiceRegistryImplementor$ServiceBinding


  }

  @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


    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

      sessionFactory.addObserver( new SchemaCreator() );
    }
  }

  private boolean currentDialectIsNeo4j(SessionFactoryImplementor sessionFactoryImplementor) {
    ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry();

    return registry.getService( ConfigurationService.class ).isOgmOn()
        && ( registry.getService( DatastoreProvider.class ) instanceof Neo4jDatastoreProvider );
  }
View Full Code Here

  private static class SchemaCreator implements SessionFactoryObserver {

    @Override
    public void sessionFactoryCreated(SessionFactory factory) {
      SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) factory;
      ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry();
      Neo4jDatastoreProvider provider = (Neo4jDatastoreProvider) registry.getService( DatastoreProvider.class );
      Set<String> sequences = sequenceGeneratorKeys( sessionFactoryImplementor, provider );
      provider.getSequenceGenerator().createUniqueConstraint( sequences );
    }
View Full Code Here

      sessionFactory.addObserver( new SequenceCreator() );
    }
  }

  private boolean currentDialectIsNeo4j(SessionFactoryImplementor sessionFactoryImplementor) {
    ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry();

    return registry.getService( ConfigurationService.class ).isOgmOn()
        && ( registry.getService( DatastoreProvider.class ) instanceof Neo4jDatastoreProvider );
  }
View Full Code Here

  private static class SequenceCreator implements SessionFactoryObserver {

    @Override
    public void sessionFactoryCreated(SessionFactory factory) {
      SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) factory;
      ServiceRegistryImplementor registry = sessionFactoryImplementor.getServiceRegistry();
      Neo4jDatastoreProvider provider = (Neo4jDatastoreProvider) registry.getService( DatastoreProvider.class );
      Set<IdentifierGenerator> sequences = sequences( sessionFactoryImplementor, provider );
      provider.getSequenceGenerator().createSequences( sequences );
    }
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

    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

    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 Mapping mapping) 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( DatastoreServices.class ).getGridDialect();

    tableName = persistentClass.getTable().getQualifiedName(
        factory.getDialect(),
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
    );
    discriminatorValue = persistentClass.getSubclassId();
    discriminatorSQLValue = String.valueOf( persistentClass.getSubclassId() );

    // SUBCLASSES

    //We do not need a discriminator as each entity type will be in its own key "space" roughly like a
    //UnionSubclassEntityPersister / table-per-concrete-class implementation
    subclassByDiscriminatorValue.put(
        persistentClass.getSubclassId(),
        persistentClass.getEntityName()
    );
    if ( persistentClass.isPolymorphic() ) {
      @SuppressWarnings( "unchecked" )
      Iterator<Subclass> iter = persistentClass.getSubclassIterator();
      while ( iter.hasNext() ) {
        Subclass sc = iter.next();
        subclassByDiscriminatorValue.put( sc.getSubclassId(), sc.getEntityName() );
      }
    }

    //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$ServiceBinding

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.