On 9/21/05, Alex Epshteyn <[EMAIL PROTECTED]> wrote:
> MySQL gives me an error when Torque attempts to execute my generated
> .sql file.  This happens because the a CREATE TABLE statement has a
> foreign key pointing to a table that hasn't been created yet.
> 
> There are two possible ways I can think of to resolve this problem,
> but don't know how to implement them in the XDoclet/Torque framework.
> Perhaps someone could help.
> 
> 1.  Insert "SET FOREIGN_KEY_CHECKS = 0;" at the beginning of and "SET
> FOREIGN_KEY_CHECKS = 1;" at the end of the project-schema.sql file.
> Is there any way to get Torque to do this when it generates that file?
> 
> 2.  Control the order in which XDoclet generates the table
> descriptions in the project-schema.xml file.  As far as I know there
> is no way of doing this.  Is there?
> 
> All other solutions I can think of would be hacks.

There is a third solution. MySQL (as every other database that I know)
is able to add foreign keys via ALTER TABLE statements. Eg. first all
tables are created, and then they are altered to add the foreign keys.
You could try DdlUtils (http://db.apache.org/ddlutils) which does
exactly this and is compatible to the Torque schema XML.

Tom

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

Reply via email to