/* */ }
/* */
/* 247 */ JDBCAbstractCMRFieldBridge[] cmrFields = this.entity.getCMRFields();
/* 248 */ for (int i = 0; i < cmrFields.length; i++)
/* */ {
/* 250 */ JDBCAbstractCMRFieldBridge cmrField = cmrFields[i];
/* 251 */ JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData();
/* */
/* 254 */ EntityBridge relatedEntity = cmrField.getRelatedEntity();
/* 255 */ if ((!relationMetaData.isTableMappingStyle()) || (!createdTables.contains(relatedEntity.getEntityName())))
/* */ continue;
/* 257 */ DataSource dataSource = relationMetaData.getDataSource();
/* */
/* 259 */ boolean relTableExisted = SQLUtil.tableExists(cmrField.getQualifiedTableName(), this.entity.getDataSource());
/* */
/* 261 */ if (relTableExisted)
/* */ {
/* 263 */ if (relationMetaData.getAlterTable())
/* */ {
/* 265 */ ArrayList oldNames = SQLUtil.getOldColumns(cmrField.getQualifiedTableName(), dataSource).getColumnNames();
/* 266 */ ArrayList newNames = new ArrayList();
/* 267 */ JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields();
/* 268 */ JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields();
/* 269 */ JDBCFieldBridge[] fields = new JDBCFieldBridge[leftKeys.length + rightKeys.length];
/* 270 */ System.arraycopy(leftKeys, 0, fields, 0, leftKeys.length);
/* 271 */ System.arraycopy(rightKeys, 0, fields, leftKeys.length, rightKeys.length);
/* */
/* 274 */ boolean different = false;
/* 275 */ for (int j = 0; j < fields.length; j++)
/* */ {
/* 277 */ JDBCFieldBridge field = fields[j];
/* */
/* 279 */ String name = field.getJDBCType().getColumnNames()[0].toUpperCase();
/* 280 */ newNames.add(name);
/* */
/* 282 */ if (oldNames.contains(name))
/* */ continue;
/* 284 */ different = true;
/* 285 */ break;
/* */ }
/* */
/* 289 */ if (!different)
/* */ {
/* 291 */ Iterator it = oldNames.iterator();
/* 292 */ while (it.hasNext())
/* */ {
/* 294 */ String name = (String)(String)it.next();
/* 295 */ if (!newNames.contains(name))
/* */ {
/* 297 */ different = true;
/* 298 */ break;
/* */ }
/* */ }
/* */ }
/* */
/* 303 */ if (different)
/* */ {
/* 306 */ this.log.error("CMR table structure is incorrect for " + cmrField.getQualifiedTableName());
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */
/* 315 */ if ((!relationMetaData.isTableMappingStyle()) || (relationMetaData.isTableCreated()))
/* */ continue;
/* 317 */ if (relationMetaData.getCreateTable())
/* */ {
/* 319 */ createTable(dataSource, cmrField.getQualifiedTableName(), getRelationCreateTableSQL(cmrField, dataSource));
/* */ }
/* */ else
/* */ {
/* 324 */ this.log.debug("Relation table not created as requested: " + cmrField.getQualifiedTableName());
/* */ }
/* */
/* 327 */ createCMRIndex(dataSource, cmrField);
/* */
/* 329 */ if (!relationMetaData.getCreateTable())
/* */ continue;
/* 331 */ issuePostCreateSQL(dataSource, relationMetaData.getDefaultTablePostCreateCmd(), cmrField.getQualifiedTableName());
/* */ }
/* */ }