protected void buildRelationTableFields(ManagedClass managedClass,Attribute managedAttribute,LinkedList<Entity> intrinsicEntity,LinkedList<Attribute> intrinsicAttribute,boolean inverse,boolean isInherited,ForeignReferenceMapping mapping,TableDefinition table,List<DatabaseField> fkFields,List<DatabaseField> targetFields){
  assert fkFields.size() > 0 && fkFields.size() == targetFields.size();
  DatabaseField fkField;
  DatabaseField targetField=null;
  List<String> fkFieldNames=new ArrayList();
  List<String> targetFieldNames=new ArrayList();
  for (int index=0; index < fkFields.size(); index++) {
    fkField=fkFields.get(index);
    targetField=targetFields.get(index);
    fkFieldNames.add(fkField.getNameDelimited(databasePlatform));
    targetFieldNames.add(targetField.getNameDelimited(databasePlatform));
    fkField=resolveDatabaseField(fkField,targetField);
    setFieldToRelationTable(intrinsicEntity.get(0),intrinsicAttribute,managedAttribute,inverse,isInherited,fkField,table);
  }
  DatabaseTable targetTable=targetField.getTable();
  TableDefinition targetTblDef=getTableDefFromDBTable(managedClass,managedAttribute,intrinsicEntity,targetTable);
  if (mapping.getDescriptor().hasTablePerClassPolicy()) {
    return;
  }
  if (mapping.getReferenceDescriptor().hasTablePerClassPolicy() && mapping.getReferenceDescriptor().getTablePerClassPolicy().hasChild()) {
    return;
  }
  addForeignKeyConstraint(table,targetTblDef,fkFieldNames,targetFieldNames,mapping.isCascadeOnDeleteSetOnDatabase());
}

protected void buildRelationTableFields ( ManagedClass managedClass , Attribute managedAttribute , LinkedList < Entity > intrinsicEntity , LinkedList < Attribute > intrinsicAttribute , boolean inverse , boolean isInherited , ForeignReferenceMapping mapping , TableDefinition table , List < DatabaseField > fkFields , List < DatabaseField > targetFields ) { assert fkFields . size ( ) > 0 && fkFields . size ( ) == targetFields . size ( ) ; DatabaseField fkField ; DatabaseField targetField = null ; List < String > fkFieldNames = new ArrayList ( ) ; List < String > targetFieldNames = new ArrayList ( ) ; for ( int index = 0 ; index < fkFields . size ( ) ; index ++ ) { fkField = fkFields . get ( index ) ; targetField = targetFields . get ( index ) ; fkFieldNames . add ( fkField . getNameDelimited ( databasePlatform ) ) ; targetFieldNames . add ( targetField . getNameDelimited ( databasePlatform ) ) ; fkField = resolveDatabaseField ( fkField , targetField ) ; setFieldToRelationTable ( intrinsicEntity . get ( 0 ) , intrinsicAttribute , managedAttribute , inverse , isInherited , fkField , table ) ; } DatabaseTable targetTable = targetField . getTable ( ) ; TableDefinition targetTblDef = getTableDefFromDBTable ( managedClass , managedAttribute , intrinsicEntity , targetTable ) ; if ( mapping . getDescriptor ( ) . hasTablePerClassPolicy ( ) ) { return ; } if ( mapping . getReferenceDescriptor ( ) . hasTablePerClassPolicy ( ) && mapping . getReferenceDescriptor ( ) . getTablePerClassPolicy ( ) . hasChild ( ) ) { return ; } addForeignKeyConstraint ( table , targetTblDef , fkFieldNames , targetFieldNames , mapping . isCascadeOnDeleteSetOnDatabase ( ) ) ; }
build field definitions and foreign key constraints for all many - to - many relation table .
