Dear John, When I have time, after delivering this application, I will come back and see what it takes to support the null in foreign keys, it certainly makes the actions and users peer code cleaner. What I did in the end was reomve the definition of the foreign keys from the XML schema and add the methods (now not generated due to lack of foreign key) into the generated peer classes that return 'parent' objects of the type related through the ex-foreign key.
I found something else to, unrelated, but still going to cause problems sometimes. In the class TorqueJDBCTransformTask the method generateXML never closes the connection it opens. Oracle has a OPEN_CURSORS limit of 64 as standard which is soon used up when you use this class to generate the XML description for a medium sized database. I did not fix it so I can't give you a diff. Regards David -----Original Message----- From: jmcnally [mailto:jmcnally]On Behalf Of John McNally Sent: 26 November 2001 17:13 To: Turbine Users List Subject: Re: Support for no constraint on the foreign key with Oracle The preferred solution would be to fix torque, so that it produces the needed sql. As you say you are not comfortable with this, I guess you can alter the scripts by hand. john mcnally David Wynter wrote: > > Hello, > > I built an application using the TDK2.1 with MySQL as the database. I have a > number of tables with optional foreign keys. In other words, a table can > have three different mutually exclusive contexts represented by 3 different > parent tables. Thus it would have 3 foreign keys defined but with only one > populated and the other 2 are NULL. This is no problem with MySQL and the > classes produced by Torque allow this optionality of foreign. > > I have switched to Oracle and it is stricter about foreign keys (i.e. it has > them!). It would not allow nulls in the 2 foreign keys that were not > populated. Now Oracle will allow nulls in foreign keys but you have to use a > constraint directive when they are foreign keys (I think eg. ...CONSTRAINT > context1 NULL...) and Torque does not support this. > > Before I approach this I thought that the experienced Turbine users might > give me guidance on approach. I figure I have 3 options: > 1. Remove the foreign key statements from my project-schema.sql and manage > these relationships in my Actions, quite alot of work. > 2. Modify the SQL produced by Torque to include the extra constraint > statements and run the SQL script independently of Torque. Maybe even > produce my own independent script with just the alter table bits e.g. "ALTER > TABLE blah ADD (fk1_column NUMBER(20) CONSTRAINT NULL, fk2_column NUMBER(20) > CONSTRAINT NULL, fk3_column NUMBER(20) CONSTRAINT NULL)" > 3. Alter the database.dtd to support the extra clause required and alter > Torque to produce the extra SQL, (not really considering this as it requires > more knowledge than I have). > > Please let me know if my logic is flawed here. 2 is my preferred option as > it means I do not have to change my actions code. > > Thanks > > David > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
