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 Marc Berman <br...@yahoo.com> on 2003/12/22 21:19:15 UTC

Foreign Key Problems

I'm currently using Torque 3.1. 

I have the following schema:

<database
  name="bookstore"
  defaultIdMethod="none">

    <table name="MASTER">
        <column name="C1" primaryKey="true"
required="true"
            size="32" type="VARCHAR"/>
        <column name="C2" primaryKey="true"
required="true"
            size="32" type="VARCHAR"/>
    </table>
    <table name="DETAIL">
        <column name="R1C1" primaryKey="true"
            required="true" size="32" type="VARCHAR"/>
        <column name="R1C2" primaryKey="true"
required="true"
            size="32" type="VARCHAR"/>
        <column name="R2C1" primaryKey="true"
            required="true" size="32" type="VARCHAR"/>
        <column name="R2C2" primaryKey="true"
required="true"
            size="32" type="VARCHAR"/>
        <foreign-key foreignTable="MASTER">
            <reference foreign="C1" local="R1C1"/>
            <reference foreign="C2" local="R1C2"/>
        </foreign-key>
        <foreign-key foreignTable="MASTER">
            <reference foreign="C1" local="R2C1"/>
            <reference foreign="C2" local="R2C2"/>
        </foreign-key>
    </table>
</database>

I'm able to build the java files without problems.
However, when I then complile the java files (via ant
-f build-torque.xml compile) I receive compilation
errors like the following:

    [javac]
/home/mhberman/torque-gen-3.1/src/java/com/kazmier/dm/BaseMaster.jav
a:132: cannot resolve symbol
    [javac] symbol  : variable
collDetailsRelatedByR2c2
    [javac] location: class com.kazmier.dm.BaseMaster
    [javac]                
((Detail)collDetailsRelatedByR2c2.get(i))


The problem only occurs under the following
conditions:

- Multiple 1-M relationships between master and the
same detail table.
The master table primary key has more than one column.

Any ideas?

Thx,
Marc

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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


AW: count(*) implementation

Posted by Dieter Engelhardt <Di...@Iris-Solutions.de>.
Hi Hassan,
here is a example how i solved it:

protected Object getTourCount() throws Exception
{
	List v = BasePeer.executeQuery("select count(*) as tourcnt from tb_tour");
	return v.get(0);
}

Cheers
Dieter

-----Ursprungliche Nachricht-----
Von: Hassan Abolhassani [mailto:Hassan.Abolhassani@razorfish.co.jp]
Gesendet: Freitag, 26. Dezember 2003 10:33
An: Apache Torque Users List
Betreff: count(*) implementation


Hi,

What is the best way to implement a query like following in Torque:

  select count(*) from table1, table2 
  where table1.id=table2.id and table2.field='something'

I want to have a function in peer class of table1 like:

  public static int getCount()

That returns the result of that count.

___

Razorfish Japan, Inc.

アボルハッサニ ハッサン   Hassan Abolhassani  [Technology network]
株式会社 レーザーフィッシュ・ジャパン
Hassan.Abolhassani@razorfish.co.jp
Tel:03-5436-9980 Fax:03-5436-9126


---------------------------------------------------------------------
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


count(*) implementation

Posted by Hassan Abolhassani <Ha...@razorfish.co.jp>.
Hi,

What is the best way to implement a query like following in Torque:

  select count(*) from table1, table2 
  where table1.id=table2.id and table2.field='something'

I want to have a function in peer class of table1 like:

  public static int getCount()

That returns the result of that count.

___

Razorfish Japan, Inc.

アボルハッサニ ハッサン   Hassan Abolhassani  [Technology network]
株式会社 レーザーフィッシュ・ジャパン
Hassan.Abolhassani@razorfish.co.jp
Tel:03-5436-9980 Fax:03-5436-9126


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