Package org.hibernate.metamodel.relational

Examples of org.hibernate.metamodel.relational.Schema


    final Schema.Name schemaName = Helper.determineDatabaseSchemaName(
        attributeSource.getExplicitSchemaName(),
        attributeSource.getExplicitCatalogName(),
        currentBindingContext
    );
    final Schema schema = metadata.getDatabase().locateSchema( schemaName );

    final String tableName = attributeSource.getExplicitCollectionTableName();
    if ( StringHelper.isNotEmpty( tableName ) ) {
      final Identifier tableIdentifier = Identifier.toIdentifier(
          currentBindingContext.getNamingStrategy().tableName( tableName )
      );
      Table collectionTable = schema.locateTable( tableIdentifier );
      if ( collectionTable == null ) {
        collectionTable = schema.createTable( tableIdentifier );
      }
      pluralAttributeBinding.setCollectionTable( collectionTable );
    }
    else {
      // todo : not sure wel have all the needed info here in all cases, specifically when needing to know the "other side"
      final EntityBinding owner = pluralAttributeBinding.getContainer().seekEntityBinding();
      final String ownerTableLogicalName = Table.class.isInstance( owner.getPrimaryTable() )
          ? Table.class.cast( owner.getPrimaryTable() ).getTableName().getName()
          : null;
      String collectionTableName = currentBindingContext.getNamingStrategy().collectionTableName(
          owner.getEntity().getName(),
          ownerTableLogicalName,
          null,  // todo : here
          null,  // todo : and here
          pluralAttributeBinding.getContainer().getPathBase() + '.' + attributeSource.getName()
      );
      collectionTableName = quoteIdentifier( collectionTableName );
      pluralAttributeBinding.setCollectionTable(
          schema.locateOrCreateTable(
              Identifier.toIdentifier(
                  collectionTableName
              )
          )
      );
View Full Code Here


  }

  private static void bind(MetadataImplementor metadata, AnnotationInstance tableAnnotation) {
    String tableName = JandexHelper.getValue( tableAnnotation, "appliesTo", String.class );
    ObjectName objectName = new ObjectName( tableName );
    Schema schema = metadata.getDatabase().getSchema( objectName.getSchema(), objectName.getCatalog() );
    Table table = schema.locateTable( objectName.getName() );
    if ( table != null ) {
      bindHibernateTableAnnotation( table, tableAnnotation );
    }
  }
View Full Code Here

  }

  private static void bind(MetadataImplementor metadata, AnnotationInstance tableAnnotation) {
    String tableName = JandexHelper.getValue( tableAnnotation, "appliesTo", String.class );
    ObjectName objectName = new ObjectName( tableName );
    Schema schema = metadata.getDatabase().getSchema( objectName.getSchema(), objectName.getCatalog() );
    Table table = schema.locateTable( objectName.getName() );
    if ( table != null ) {
      bindHibernateTableAnnotation( table, tableAnnotation );
    }
  }
View Full Code Here

    params.putAll( properties );

    // use the schema/catalog specified by getValue().getTable() - but note that
    // if the schema/catalog were specified as params, they will already be initialized and
    //will override the values set here (they are in idGenerator.getParameters().)
    Schema schema = getValue().getTable().getSchema();
    if ( schema != null ) {
      if ( schema.getName().getSchema() != null ) {
        params.setProperty( PersistentIdentifierGenerator.SCHEMA, schema.getName().getSchema().getName() );
      }
      if ( schema.getName().getCatalog() != null ) {
        params.setProperty( PersistentIdentifierGenerator.CATALOG, schema.getName().getCatalog().getName() );
      }
    }

    // TODO: not sure how this works for collection IDs...
    //pass the entity-name, if not a collection-id
View Full Code Here

    getHibernateXmlBinder().getMetadata().addEntity( entityBinding );
  }

  private void basicTableBinding(Element entityElement, EntityBinding entityBinding) {
    final Schema schema = getHibernateXmlBinder().getMetadata().getDatabase().getSchema( schemaName );

    final String subSelect = HbmHelper.getSubselect( entityElement );
    if ( subSelect != null ) {
      final String logicalName = entityBinding.getEntity().getName();
      InLineView inLineView = schema.getInLineView( logicalName );
      if ( inLineView == null ) {
        inLineView = schema.createInLineView( logicalName, subSelect );
      }
      entityBinding.setBaseTable( inLineView );
    }
    else {
      final Identifier tableName = Identifier.toIdentifier( getClassTableName( entityElement, entityBinding, null ) );
      org.hibernate.metamodel.relational.Table table = schema.getTable( tableName );
      if ( table == null ) {
        table = schema.createTable( tableName );
      }
      entityBinding.setBaseTable( table );
      Element comment = entityElement.element( "comment" );
      if ( comment != null ) {
        table.addComment( comment.getTextTrim() );
View Full Code Here

            schmaName = StringHelper.quote( schmaName );
            catalogName = StringHelper.quote( catalogName );
            tableName = StringHelper.quote( tableName );
        }
        final Identifier tableNameIdentifier = Identifier.toIdentifier( tableName );
        final Schema schema = meta.getDatabase().getSchema( new Schema.Name( schmaName, catalogName ) );
        Table table = schema.getTable( tableNameIdentifier );
        if ( table == null ) {
            table = schema.createTable( tableNameIdentifier );
        }
        return table;
    }
View Full Code Here

    getMetadata().addEntity( entityBinding );
  }

  private void basicTableBinding(XMLClass xmlClazz,
                   EntityBinding entityBinding) {
    final Schema schema = getMetadata().getDatabase().getSchema( getSchemaName() );

    final String subSelect =
        xmlClazz.getSubselectAttribute() == null ? xmlClazz.getSubselect() : xmlClazz.getSubselectAttribute();
    if ( subSelect != null ) {
      final String logicalName = entityBinding.getEntity().getName();
      InLineView inLineView = schema.getInLineView( logicalName );
      if ( inLineView == null ) {
        inLineView = schema.createInLineView( logicalName, subSelect );
      }
      entityBinding.setBaseTable( inLineView );
    }
    else {
            String classTableName = getClassTableName( xmlClazz, entityBinding, null );
            if(getBindingContext().isGloballyQuotedIdentifiers()){
                classTableName = StringHelper.quote( classTableName );
            }
      final Identifier tableName = Identifier.toIdentifier( classTableName );
      org.hibernate.metamodel.relational.Table table = schema.getTable( tableName );
      if ( table == null ) {
        table = schema.createTable( tableName );
      }
      entityBinding.setBaseTable( table );
      String comment = xmlClazz.getComment();
      if ( comment != null ) {
        table.addComment( comment.trim() );
View Full Code Here

  }

  private static void bind(MetadataImplementor metadata, AnnotationInstance tableAnnotation) {
    String tableName = JandexHelper.getValueAsString( tableAnnotation, "appliesTo" );
    ObjectName objectName = new ObjectName( tableName );
    Schema schema = metadata.getDatabase().getSchema( objectName.getSchema(), objectName.getCatalog() );
    Table table = schema.getTable( objectName.getName() );
    if ( table != null ) {
      bindHibernateTableAnnotation( table, tableAnnotation );
    }
  }
View Full Code Here

    params.putAll( properties );

    // use the schema/catalog specified by getValue().getTable() - but note that
    // if the schema/catalog were specified as params, they will already be initialized and
    //will override the values set here (they are in idGenerator.getParameters().)
    Schema schema = getValue().getTable().getSchema();
    if ( schema != null ) {
      if ( schema.getName().getSchema() != null ) {
        params.setProperty( PersistentIdentifierGenerator.SCHEMA, schema.getName().getSchema().getName() );
      }
      if ( schema.getName().getCatalog() != null ) {
        params.setProperty(PersistentIdentifierGenerator.CATALOG, schema.getName().getCatalog().getName() );
      }
    }

    // TODO: not sure how this works for collection IDs...
    //pass the entity-name, if not a collection-id
View Full Code Here

    getMetadata().addEntity( entityBinding );
  }

  private void basicTableBinding(XMLClass xmlClazz,
                   EntityBinding entityBinding) {
    final Schema schema = getMetadata().getDatabase().getSchema( getSchemaName() );

    final String subSelect =
        xmlClazz.getSubselectAttribute() == null ? xmlClazz.getSubselect() : xmlClazz.getSubselectAttribute();
    if ( subSelect != null ) {
      final String logicalName = entityBinding.getEntity().getName();
      InLineView inLineView = schema.getInLineView( logicalName );
      if ( inLineView == null ) {
        inLineView = schema.createInLineView( logicalName, subSelect );
      }
      entityBinding.setBaseTable( inLineView );
    }
    else {
      final Identifier tableName = Identifier.toIdentifier( getClassTableName( xmlClazz, entityBinding, null ) );
      org.hibernate.metamodel.relational.Table table = schema.getTable( tableName );
      if ( table == null ) {
        table = schema.createTable( tableName );
      }
      entityBinding.setBaseTable( table );
      String comment = xmlClazz.getComment();
      if ( comment != null ) {
        table.addComment( comment.trim() );
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.relational.Schema

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.