private void discoverMany2ManyAssociationsFor(String source, String dbName) { for (String potentialJoinTable : metaModels.getTableNames(dbName)) { String target = Inflector.getOtherName(source, potentialJoinTable); if (target != null && getMetaModel(target) != null && hasForeignKeys(potentialJoinTable, source, target)) { Class<? extends Model> sourceModelClass = metaModels.getModelClass(source); Class<? extends Model> targetModelClass = metaModels.getModelClass(target); Association associationSource = new Many2ManyAssociation(sourceModelClass, targetModelClass, potentialJoinTable, getMetaModel(source).getFKName(), getMetaModel(target).getFKName()); getMetaModel(source).addAssociation(associationSource); } } }
private void discoverMany2ManyAssociationsFor(String source, String dbName) { for (String join : metaModels.getTableNames(dbName)) { String other = Inflector.getOtherName(source, join); if (other == null || getMetaModel(other) == null || !hasForeignKeys(join, source, other)) continue; Association associationSource = new Many2ManyAssociation(source, other, join, getMetaModel(source).getFKName(), getMetaModel(other).getFKName()); getMetaModel(source).addAssociation(associationSource); } }
private void discoverMany2ManyAssociationsFor(String source, String dbName) { for (String potentialJoinTable : metaModels.getTableNames(dbName)) { String target = Inflector.getOtherName(source, potentialJoinTable); if (target != null && getMetaModel(target) != null && hasForeignKeys(potentialJoinTable, source, target)) { Class<? extends Model> sourceModelClass = metaModels.getModelClass(source); Class<? extends Model> targetModelClass = metaModels.getModelClass(target); Association associationSource = new Many2ManyAssociation(sourceModelClass, targetModelClass, potentialJoinTable, getMetaModel(source).getFKName(), getMetaModel(target).getFKName()); getMetaModel(source).addAssociation(associationSource); } } }