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

Generated class problem

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: Generated class problem

Posted by Luca Zappa <lu...@lucazappa.com>.
Hi Nathan,
  I have genereted (without Maven) your simple schema with Torque 3.1 and
the two methods are included in BaseOrder class (see the attachment).

public Customer getCustomer() throws TorqueException 
public void setCustomer(Customer v) throws TorqueException


Regards,
 Luca

-----Original Message-----
From: Nathan Mcminn [mailto:NMcminn@theblragency.com] 
Sent: Friday, March 12, 2004 6:31 PM
To: torque-user@db.apache.org
Subject: Generated class problem

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