db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <tfisc...@apache.org>
Subject RE: Creating foreign key constraints on tables that already exists in the database
Date Sun, 19 Feb 2006 10:46:13 GMT
An additional idea would be to add a dummy definition of the tables and 
set the skipsql attribue (tells the generator not to produce sql for this 
table). Of course the om objects are still created.

        Thomas

On Fri, 17 Feb 2006, Greg Monroe wrote:

> There can't be a "ignore missing forgeign key" option.  This
> is because if you define a forgeign key in Torque, it adds
> methods to support the relationship.  The methods depend on
> having the generated classes for the forgeign key table, so
> ignoring it will lead to compile time errors.
>
> You have a couple of choices here.  First, why not just add
> the schema definitions for the tables?  If you use the jdbc
> ant task (I think that's the one), you can extract 90% of
> the schema info you need (still might need some minor
> tweaking to be accurate).
>
> One variation of this is to use different schema xml file
> for the "external" db schema and a project schema xml file
> for your application objects.  Look thru the docs for info
> on how to have multiple DB schema files that can be linked.
>
> The other option is to just not define those fields as being
> forgeign keys in the XML schema.  If you need special
> processing when using them, just override the base set/get
> methods in the Table.java subclass.
>
>> -----Original Message-----
>> From: Francois Guitton [mailto:fguitton@coemergence.com]
>> Sent: Friday, February 17, 2006 8:34 AM
>> To: torque-user@db.apache.org
>> Subject: Creating foreign key constraints on tables that
>> already exists in the database
>>
>>
>> Hi
>>
>>
>>
>> Is there a way with the generator to create new tables that
>> have foreign key that reference already existing tables?
>>
>>
>>
>> E.g. I have a database where the tables Product  (primary key
>> product_id) and Client (primary key client_id) already exists.
>>
>> Now I want to use the generator to create a joined table
>> Product_Client that have two foreign keys
>>
>> So my xml would look like
>>
>>   <table idMethod="native" name="Product_Client">
>>
>>     <column name="product_client_id" primaryKey="true"
>> required="true" type="INTEGER"/>
>>
>>     <column name="product_id" required="true" type="INTEGER"/>
>>
>>     <column name="client_id" required="true" type="INTEGER"/>
>>
>>         <foreign-key foreignTable="Client">
>>
>>             <reference foreign="client_id" local="client_id"/>
>>
>>         </foreign-key>
>>
>>         <foreign-key foreignTable="Product">
>>
>>             <reference foreign="product_id" local="product_id"/>
>>
>>         </foreign-key>
>>
>>   </table>
>>
>>
>>
>> Torque doesn't like it when generating the sql as it doesn't
>> find the referenced tables. Could there be an option in
>> Torque where it just generates a warning that the table does
>> not exist but still create the sql?
>>
>>
>>
>>
>>
>>
>
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it are confidential
communication or may otherwise be privileged or confidential and are intended solely for the
individual or entity to whom they are addressed.  If you are not the intended recipient you
may not rely on the contents of this email or any attachments, and we ask that you  please
not read, copy or retransmit this communication, but reply to the sender and destroy the email,
its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution
or copying of this communication is strictly prohibited.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message