Package org.hibernate.cfg.annotations

Examples of org.hibernate.cfg.annotations.TableBinder


      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );
    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;
      final javax.persistence.Index[] jpaIndexes;


      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
        jpaIndexes = collectionTable.indexes();
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
        jpaIndexes = assocTable.indexes();
      }

      collectionBinder.setExplicitAssociationTable( true );
      if ( jpaIndexes != null && jpaIndexes.length > 0 ) {
        associationTableBinder.setJpaIndex( jpaIndexes );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );
      associationTableBinder.setJpaIndex( jpaIndexes );
      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here


  private static void bindJoinedTableAssociation(
      JoinTable joinTableAnn, ExtendedMappings mappings, EntityBinder entityBinder,
      CollectionBinder collectionBinder, PropertyHolder propertyHolder, PropertyData inferredData,
      String mappedBy
  ) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    if ( joinTableAnn != null ) {
      collectionBinder.setExplicitAssociationTable( true );
      if ( !BinderHelper.isDefault( joinTableAnn.schema() ) )
        associationTableBinder.setSchema( joinTableAnn.schema() );
      if ( !BinderHelper.isDefault( joinTableAnn.catalog() ) )
        associationTableBinder.setCatalog( joinTableAnn.catalog() );
      if ( !BinderHelper.isDefault( joinTableAnn.name() ) ) associationTableBinder.setName( joinTableAnn.name() );
      associationTableBinder.setUniqueConstraints( joinTableAnn.uniqueConstraints() );

      //set check constaint in the second pass

      JoinColumn[] joins = joinTableAnn.joinColumns();

      if ( joins.length == 0 ) {
        annJoins = null;
      }
      else {
        annJoins = joins;
      }

      JoinColumn[] inverseJoins = joinTableAnn.inverseJoinColumns();

      if ( inverseJoins.length == 0 ) {
        annInverseJoins = null;
      }
      else {
        annInverseJoins = inverseJoins;
      }
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isEmptyAnnotationValue( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

  private static void bindJoinedTableAssociation(
      XProperty property, ExtendedMappings mappings, EntityBinder entityBinder,
      CollectionBinder collectionBinder, PropertyHolder propertyHolder, PropertyData inferredData,
      String mappedBy
  ) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if (collectionTable != null) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isDefault( schema ) ) associationTableBinder.setSchema( schema );
      if ( !BinderHelper.isDefault( catalog ) ) associationTableBinder.setCatalog( catalog );
      if ( !BinderHelper.isDefault( tableName ) ) associationTableBinder.setName( tableName );
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isEmptyAnnotationValue( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

  private static void bindJoinedTableAssociation(
      JoinTable joinTableAnn, ExtendedMappings mappings, EntityBinder entityBinder,
      CollectionBinder collectionBinder, PropertyHolder propertyHolder, PropertyData inferredData,
      String mappedBy
  ) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    if ( joinTableAnn != null ) {
      collectionBinder.setExplicitAssociationTable( true );
      if ( ! BinderHelper.isDefault( joinTableAnn.schema() ) ) associationTableBinder.setSchema( joinTableAnn.schema() );
      if ( ! BinderHelper.isDefault( joinTableAnn.catalog() ) ) associationTableBinder.setCatalog( joinTableAnn.catalog() );
      if ( ! BinderHelper.isDefault( joinTableAnn.name() ) ) associationTableBinder.setName( joinTableAnn.name() );
      associationTableBinder.setUniqueConstraints( joinTableAnn.uniqueConstraints() );

      //set check constaint in the second pass

      JoinColumn[] joins = joinTableAnn.joinColumns();

      if ( joins.length == 0 ) {
        annJoins = null;
      }
      else {
        annJoins = joins;
      }

      JoinColumn[] inverseJoins = joinTableAnn.inverseJoinColumns();

      if ( inverseJoins.length == 0 ) {
        annInverseJoins = null;
      }
      else {
        annInverseJoins = inverseJoins;
      }
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isDefault( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isDefault( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isDefault( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isEmptyAnnotationValue( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isEmptyAnnotationValue( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

      EntityBinder entityBinder,
      CollectionBinder collectionBinder,
      PropertyHolder propertyHolder,
      PropertyData inferredData,
      String mappedBy) {
    TableBinder associationTableBinder = new TableBinder();
    JoinColumn[] annJoins;
    JoinColumn[] annInverseJoins;
    JoinTable assocTable = propertyHolder.getJoinTable( property );
    CollectionTable collectionTable = property.getAnnotation( CollectionTable.class );

    if ( assocTable != null || collectionTable != null ) {

      final String catalog;
      final String schema;
      final String tableName;
      final UniqueConstraint[] uniqueConstraints;
      final JoinColumn[] joins;
      final JoinColumn[] inverseJoins;

      //JPA 2 has priority
      if ( collectionTable != null ) {
        catalog = collectionTable.catalog();
        schema = collectionTable.schema();
        tableName = collectionTable.name();
        uniqueConstraints = collectionTable.uniqueConstraints();
        joins = collectionTable.joinColumns();
        inverseJoins = null;
      }
      else {
        catalog = assocTable.catalog();
        schema = assocTable.schema();
        tableName = assocTable.name();
        uniqueConstraints = assocTable.uniqueConstraints();
        joins = assocTable.joinColumns();
        inverseJoins = assocTable.inverseJoinColumns();
      }

      collectionBinder.setExplicitAssociationTable( true );

      if ( !BinderHelper.isEmptyAnnotationValue( schema ) ) {
        associationTableBinder.setSchema( schema );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( catalog ) ) {
        associationTableBinder.setCatalog( catalog );
      }
      if ( !BinderHelper.isEmptyAnnotationValue( tableName ) ) {
        associationTableBinder.setName( tableName );
      }
      associationTableBinder.setUniqueConstraints( uniqueConstraints );

      //set check constaint in the second pass
      annJoins = joins.length == 0 ? null : joins;
      annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins;
    }
    else {
      annJoins = null;
      annInverseJoins = null;
    }
    Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), mappedBy,
        mappings
    );
    Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
        annInverseJoins, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(),
        mappedBy, mappings
    );
    associationTableBinder.setMappings( mappings );
    collectionBinder.setTableBinder( associationTableBinder );
    collectionBinder.setJoinColumns( joinColumns );
    collectionBinder.setInverseJoinColumns( inverseJoinColumns );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.annotations.TableBinder

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.