attached is a fix for the multiple pk problem I reported. I can only
test in my use, further testing should be performed!
Index: src/java/org/apache/torque/engine/database/transform/XmlToAppData.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
retrieving revision 1.14
diff -r1.14 XmlToAppData.java
256,293c256
< ForeignKey fk = currTable
< .getForeignKey(attributes.getValue("local"));
< List referrers = foreignTable.getReferrers();
< if (referrers == null || !referrers.contains(fk))
< {
< foreignTable.addReferrer(fk);
< }
<
< Column local = currTable
< .getColumn(attributes.getValue("local"));
< // give notice of a schema inconsistency.
< // note we do not prevent the npe as there is nothing
< // that we can do, if it is to occur.
< if ( local == null )
< {
< System.out.println("ERROR!! Attempt to define foreign"
< + " key with nonexistent column, " +
< attributes.getValue("local") + ", in table, " +
< currTable.getName() + "!" );
< }
< //check for foreign pk's
< if (local.isPrimaryKey())
< {
< currTable.setContainsForeignPK(true);
< }
<
< Column foreign = foreignTable
< .getColumn(attributes.getValue("foreign"));
< // if the foreign column does not exist, we may have an
< // external reference or a misspelling
< if ( foreign == null )
< {
< System.out.println("ERROR!! Attempt to set foreign"
< + " key to nonexistent column, " +
< attributes.getValue("foreign") + ", in table, "
< + foreignTable.getName() + "!" );
< }
< foreign.addReferrer(fk);
---
> // This code has been moved to the endElement handler
389c352,407
<
---
> // Add referrers to foreign tables.. after all is said and done!
> if(!firstPass){
> if ("table".equals(rawName) && currTable != null){
> ForeignKey[] fks = currTable.getForeignKeys();
> // iterate foreign keys and add referers to foreign tables
> for(int keyindex = 0;keyindex<fks.length;keyindex++){
> String foreignTableName = fks[keyindex].getForeignTableName();
> Table ft = currDB.getTable(foreignTableName);
> if ( ft == null )
> {
> System.out.println("ERROR!! Attempt to set foreign"
> + " key to nonexistent table, " +
> foreignTableName + "!");
> }
> List referrers = ft.getReferrers();
> if (referrers == null || !referrers.contains(fks[keyindex])) {
> ft.addReferrer(fks[keyindex]);
> }
> // iterate reference columns
> java.util.Iterator colIter = fks[keyindex].getLocalColumns().iterator();
> while(colIter.hasNext()){
> String localColName = (String)colIter.next();
> Column local = currTable.getColumn(localColName);
> // give notice of a schema inconsistency.
> // note we do not prevent the npe as there is nothing
> // that we can do, if it is to occur.
> if ( local == null ) {
> System.out.println("ERROR!! Attempt to define foreign"
> + " key with nonexistent column, " +
> localColName + ", in table, " +
> currTable.getName() + "!" );
> } //check for foreign pk's
> if (local.isPrimaryKey())
> {
> currTable.setContainsForeignPK(true);
> }
> }
> Table foreignTable = currDB.getTable(fks[keyindex].getForeignTableName());
> colIter = fks[keyindex].getForeignColumns().iterator();
> while(colIter.hasNext()){
> String foreignColName = (String)colIter.next();
> Column foreign = foreignTable.getColumn(foreignColName);
> // if the foreign column does not exist, we may have an
> // external reference or a misspelling
> if ( foreign == null )
> {
> System.out.println("ERROR!! Attempt to set foreign"
> + " key to nonexistent column, " +
> foreignColName + ", in table, "
> + foreignTable.getName() + "!" );
> }
> foreign.addReferrer(fks[keyindex]);
> }
> }
> }
> }
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>