You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Nathan Mcminn <NM...@theblragency.com> on 2004/03/15 20:02:38 UTC

Foreign key relationships

I'm having a problem with foreign keys in torque.  We are trying to
upgrade to Torque 3.1 from an older snapshot build.  Maven is handling
the build, using torque:om.  With our older version, if we had a foreign
key defined for a given table, a method was generated in the
base<table-name> object that takes an object of the foreign table as an
argument.  For example, given the following simple schema:
 
    <table name="CUSTOMER">
        <column name="OBJECT_ID" primaryKey="true" required="true"
type="INTEGER"/>
        <column name="CUSTOMER_ID" required="true" type="INTEGER"/>
        <column name="NAME" required="true" size="40" type="VARCHAR"/>
    </table>
 
    <table name="ORDER">
        <column name="OBJECT_ID" primaryKey="true" required="true"
type="INTEGER"/>
        <column name="ITEM" required="true" size="40" type="VARCHAR"/>
        <column name="CUSTOMER_ID" required="true" type="INTEGER"/>
        <foreign-key foreignTable="CUSTOMER">
            <reference foreign="OBJECT_ID" local="CUSTOMER_ID"/>
        </foreign-key>
    </table>
 
two base<table-name> classes would be produced, BaseOrder, and
BaseCustomer. BaseOrder would have a method called getCustomer that
returned a Customer object, and a method called setCustomer(Customer c)
that takes a Customer object as an argument.
 
After generating my classes using Torque 3.1, this is no longer
happening. When I generate my classes, all Base<table-name> and
Base<table-name>Peer classes are created, but the methods I am used to
seeing for handling foreign-key relationships are gone.
 
 
--------------------------------------------
Nathan McMinn
Application Developer
NequalsOne - HealthCare marketing tools
mailto:nmcminn@NequalsOne.com
http://www.NequalsOne.com 
 

Re: Foreign key relationships

Posted by Scott Eade <se...@backstagetech.com.au>.
Nathan Mcminn wrote:

>After generating my classes using Torque 3.1, this is no longer
>happening. When I generate my classes, all Base<table-name> and
>Base<table-name>Peer classes are created, but the methods I am used to
>seeing for handling foreign-key relationships are gone.
>  
>
It looks like you are getting caught by the problem where maven doesn't 
read the default properties for the plugin, in this case complexObjectModel.

You should find answers in the mail archive, all you need to do is add 
the following to your project.properties file:

torque.addGetByNameMethod = true
torque.addIntakeRetrievable = true
torque.addSaveMethod = true
torque.addTimeStamp = false
torque.basePrefix = Base
torque.complexObjectModel = true
torque.useManagers = true
torque.useClasspath = true
torque.saveException = TorqueException
torque.retrievableInterface = org.apache.turbine.om.Retrievable

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au



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