Many thanks to Bill, Quinton and Henning (esp Bill and Quinton for not
suggesting RTFM ... :P). One small nitpick and perhaps a bug to be fixed
for torque (hence the cross-posting). When using foreign keys
capitalization is, apparently, important (which the unintiated wouldn't
have at first guessed given we're talking SQL here). i.e. if one copies the
TURBINE_USER table into one's schema with its field 'USER_ID' and then
tries to create a foreign key in another table pointing to 'user_id' a
nullpointerexception occurs pointing to:

org.apache.torque.engine.database.model.Database

The offending line (468) reads:

                    Column foreign = foreignTable
                        .getColumn((String)foreignColumnNames.next());
                    // 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, "
+
                                           foreign.getName() + ", in table,
"
                                           + foreignTable.getName() + "!"
);
                    }

Suggested fix:

                    String foreignCol = (String)foreignColumnNames.next();
                    Column foreign = foreignTable.getColumn(foreignCol);
                    // 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, "
+
                                           foreignCol + ", in table, "
                                           + foreignTable.getName() + "!"
);
                    }

Printing method results on null objects doesn't get one very far and as
this is torque 3rc2 code this could probably use patching (I checked the
cvs, it's still there - if someone wants to enlighten me on how to submit
patches I'll be glad to reformat it).
-j

-------------------------------------------------
James Diggans
Bioinformatics Programmer
Gene Logic, Inc.
Phone: 301.987.1756
FAX: 301.987.1701




                                                                                       
                   
                      "Henning P.                                                      
                   
                      Schmiedehausen"          To:       
[EMAIL PROTECTED]                  
                      <[EMAIL PROTECTED]        cc:                                     
                   
                      >                        Subject:  Re: FK to TURBINE_USER? (was 
TURBINE_* using     
                      Sent by:                  native seqs?)                          
                   
                      [EMAIL PROTECTED]                                                
                   
                      ermeta.de                                                        
                   
                                                                                       
                   
                                                                                       
                   
                      12/04/2002 01:00                                                 
                   
                      PM                                                               
                   
                      Please respond to                                                
                   
                      hps                                                              
                   
                                                                                       
                   
                                                                                       
                   




[EMAIL PROTECTED] writes:


>Here's a real question, however - how, in my schema tables, can I have a
>foreign key to a row in TURBINE_USER? Obviously one cannot put a
>foreign-key reference to tables that don't exist in one's own schema and
in
>a vain attempt to circumvent this I deleted the turbine-schema.xml file
and
>placed the table definitions directly into my own PROJECT-schema.xml file.

Yes, that's good.

>This, however, seems to cause ant to crash during the 'schema-sql' target:

Keep the turbine-schema.xml (but leave it empty, just a dummy
<database></database>) or remove the references to the
turbine-schema.xml from the build files.

Yep, the build files should react sane to missing files and report an
user readable error. Welcome to Open Source.

             Regards
                         Henning






--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to