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 Alex Laudani - Softmasters <al...@softmasters.net> on 2007/10/09 10:38:22 UTC

problem with om classes

Hello,
I have problems with generating torque classes with torque generator.
The generator is invoked using ant build from devaki nextobjects.
Below are my schema.xml file and my build.properties.
The generated BaseLibriPeer has the following problem:
at line 825 it shows:

boolean newObject = true;
            for (int j = 0; j < results.size(); j++)
            {
                Libri temp_obj1 = (Libri)results.get(j);
                Autori temp_obj2 = (Autori)temp_obj1.get();
                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
                {
                    newObject = false;
                    temp_obj2.addLibri(obj1);
                    break;
                }
            }

The problem is that
Autori temp_obj2 = (Autori)temp_obj1.get();
should be
Autori temp_obj2 = (Autori)temp_obj1.getAutori();
and so it gives an error at compile time because the get() method does not
exist in Libri.
I've tried to look at om/Peer.vm template and I can see the a
$joinTable.Interface is involved. I think that the value for
$table.Interface is not defined. How can I define it?
Thank you
Regards

schema.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<database name="" defaultIdMethod="native" defaultJavaType="primitive"
package="org.devaki.nextobjects.models" baseClass="
org.apache.torque.om.BaseObject" basePeer="org.apache.torque.util.BasePeer"
defaultJavaNamingMethod="underscore" heavyIndexing="false">

    <table name="autori" javaName="Autori" idMethod="null" baseClass="
org.apache.torque.om.BaseObject" basePeer="org.apache.torque.util.BasePeer"
interface="" javaNamingMethod="nochange" heavyIndexing="false"
description="">

        <column name="autore_id" javaName="autoreId" primaryKey="true"
required="true" type="INTEGER" javaType="object"
javaNamingMethod="javaname"/>
        <column name="nome" javaName="nome" required="true" type="VARCHAR"
javaType="object" size="255" javaNamingMethod="javaname"/>

    </table>
    <table name="libri" javaName="Libri" idMethod="null" baseClass="
org.apache.torque.om.BaseObject" basePeer="org.apache.torque.util.BasePeer"
interface="" javaNamingMethod="nochange" heavyIndexing="false"
description="">

        <column name="libro_id" javaName="libroId" primaryKey="true"
required="true" type="INTEGER" javaType="object"
javaNamingMethod="javaname"/>
        <column name="titolo" javaName="titolo" type="VARCHAR"
javaType="object" size="255" javaNamingMethod="javaname"/>
        <column name="autore_id" javaName="autoreId" required="true"
type="INTEGER" javaType="object" javaNamingMethod="javaname"/>

        <foreign-key foreignTable="autori" onUpdate="none" onDelete="none">
            <reference foreign="autore_id" local="autore_id"/>
            <reference foreign="autore_id" local="autore_id"/>

        </foreign-key>
    </table>
</database>

build.properties:
#--- properties for Torque build ---
#Tue Oct 09 01:11:11 CEST 2007
project=project1
complexObjectModel=true
databaseUrl=jdbc\:postgresql\://127.0.0.1/project1
IntakeControlTemplate=intake/Control.vm
ServiceControlTemplate=service/Control.vm
torque.database.schema=public
idTableControlTemplate=sql/id-table/Control.vm
addSaveMethod=true
createDatabaseUrl=jdbc\:postgresql\://127.0.0.1/template1
basePrefix=Base
addGetByNameMethod=true
DataSQLControlTemplate=sql/load/Control.vm
configDir=./config
databaseHost=127.0.0.1
databaseDriver=org.postgresql.Driver
OMControlTemplate=om/Control.vm
targetPackage=org.devaki.nextobjects.models
database=postgresql
documentationFormat=html
DataDumpControlTemplate=data/dump/Control.vm
DocControlTemplate=doc/Control.vm
addIntakeRetrievable=true
buildDatabaseUrl=jdbc\:postgresql\://127.0.0.1/project1
DataDTDControlTemplate=data/Control.vm
SQLControlTemplate=sql/base/Control.vm
userManagers=false
sameJavaName=false
templatePath=templates
torque.home=C\:\\Documents and Settings\\Alex\\devaki-nextobjects\\torque-
gen-3.1
databaseUser=devaki
addTimeStamp=true
outputDirectory=src
databasePassword=
schemaDirectory=schema

Re: problem with om classes

Posted by Alex Laudani - Softmasters <al...@softmasters.net>.
Removing the empty interface solves the problem.
The issue is caused by devaki-nextobjects which creates a wrong
schema.xmland adds the interface="".
Thank you
Regards

On 10/11/07, Thomas Fischer <tf...@apache.org> wrote:
>
> Hm, you have defined the foreign key twice:
> <foreign-key foreignTable="autori" onUpdate="none" onDelete="none">
>    <reference foreign="autore_id" local="autore_id"/>
>    <reference foreign="autore_id" local="autore_id"/>
> </foreign-key>
>
> perhaps removing one of the references helps ?
>
> It should not be necessary to define an interface. Can you remove the
> empty interface and see what happens ?
>
>     Thomas
>
> On Tue, 9 Oct 2007, Alex Laudani - Softmasters wrote:
>
> > Hello,
> > I have problems with generating torque classes with torque generator.
> > The generator is invoked using ant build from devaki nextobjects.
> > Below are my schema.xml file and my build.properties.
> > The generated BaseLibriPeer has the following problem:
> > at line 825 it shows:
> >
> > boolean newObject = true;
> >            for (int j = 0; j < results.size(); j++)
> >            {
> >                Libri temp_obj1 = (Libri)results.get(j);
> >                Autori temp_obj2 = (Autori)temp_obj1.get();
> >                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey
> ()))
> >                {
> >                    newObject = false;
> >                    temp_obj2.addLibri(obj1);
> >                    break;
> >                }
> >            }
> >
> > The problem is that
> > Autori temp_obj2 = (Autori)temp_obj1.get();
> > should be
> > Autori temp_obj2 = (Autori)temp_obj1.getAutori();
> > and so it gives an error at compile time because the get() method does
> not
> > exist in Libri.
> > I've tried to look at om/Peer.vm template and I can see the a
> > $joinTable.Interface is involved. I think that the value for
> > $table.Interface is not defined. How can I define it?
> > Thank you
> > Regards
> >
> > schema.xml
> >
> > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > <database name="" defaultIdMethod="native" defaultJavaType="primitive"
> > package="org.devaki.nextobjects.models" baseClass="
> > org.apache.torque.om.BaseObject" basePeer="
> org.apache.torque.util.BasePeer"
> > defaultJavaNamingMethod="underscore" heavyIndexing="false">
> >
> >    <table name="autori" javaName="Autori" idMethod="null" baseClass="
> > org.apache.torque.om.BaseObject" basePeer="
> org.apache.torque.util.BasePeer"
> > interface="" javaNamingMethod="nochange" heavyIndexing="false"
> > description="">
> >
> >        <column name="autore_id" javaName="autoreId" primaryKey="true"
> > required="true" type="INTEGER" javaType="object"
> > javaNamingMethod="javaname"/>
> >        <column name="nome" javaName="nome" required="true"
> type="VARCHAR"
> > javaType="object" size="255" javaNamingMethod="javaname"/>
> >
> >    </table>
> >    <table name="libri" javaName="Libri" idMethod="null" baseClass="
> > org.apache.torque.om.BaseObject" basePeer="
> org.apache.torque.util.BasePeer"
> > interface="" javaNamingMethod="nochange" heavyIndexing="false"
> > description="">
> >
> >        <column name="libro_id" javaName="libroId" primaryKey="true"
> > required="true" type="INTEGER" javaType="object"
> > javaNamingMethod="javaname"/>
> >        <column name="titolo" javaName="titolo" type="VARCHAR"
> > javaType="object" size="255" javaNamingMethod="javaname"/>
> >        <column name="autore_id" javaName="autoreId" required="true"
> > type="INTEGER" javaType="object" javaNamingMethod="javaname"/>
> >
> >        <foreign-key foreignTable="autori" onUpdate="none"
> onDelete="none">
> >            <reference foreign="autore_id" local="autore_id"/>
> >            <reference foreign="autore_id" local="autore_id"/>
> >
> >        </foreign-key>
> >    </table>
> > </database>
> >
> > build.properties:
> > #--- properties for Torque build ---
> > #Tue Oct 09 01:11:11 CEST 2007
> > project=project1
> > complexObjectModel=true
> > databaseUrl=jdbc\:postgresql\://127.0.0.1/project1
> > IntakeControlTemplate=intake/Control.vm
> > ServiceControlTemplate=service/Control.vm
> > torque.database.schema=public
> > idTableControlTemplate=sql/id-table/Control.vm
> > addSaveMethod=true
> > createDatabaseUrl=jdbc\:postgresql\://127.0.0.1/template1
> > basePrefix=Base
> > addGetByNameMethod=true
> > DataSQLControlTemplate=sql/load/Control.vm
> > configDir=./config
> > databaseHost=127.0.0.1
> > databaseDriver=org.postgresql.Driver
> > OMControlTemplate=om/Control.vm
> > targetPackage=org.devaki.nextobjects.models
> > database=postgresql
> > documentationFormat=html
> > DataDumpControlTemplate=data/dump/Control.vm
> > DocControlTemplate=doc/Control.vm
> > addIntakeRetrievable=true
> > buildDatabaseUrl=jdbc\:postgresql\://127.0.0.1/project1
> > DataDTDControlTemplate=data/Control.vm
> > SQLControlTemplate=sql/base/Control.vm
> > userManagers=false
> > sameJavaName=false
> > templatePath=templates
> > torque.home=C\:\\Documents and
> Settings\\Alex\\devaki-nextobjects\\torque-
> > gen-3.1
> > databaseUser=devaki
> > addTimeStamp=true
> > outputDirectory=src
> > databasePassword=
> > schemaDirectory=schema
> >
>



-- 
------------------------
Alex Laudani

Softmasters - Technology solutions
Via Dante 2/26
16121 Genova
Italy
Phone: +390108936161
GSM: +393384531234
http://www.softmasters.net
-----------------------

Re: problem with om classes

Posted by Thomas Fischer <tf...@apache.org>.
Hm, you have defined the foreign key twice:
<foreign-key foreignTable="autori" onUpdate="none" onDelete="none">
   <reference foreign="autore_id" local="autore_id"/>
   <reference foreign="autore_id" local="autore_id"/>
</foreign-key>

perhaps removing one of the references helps ?

It should not be necessary to define an interface. Can you remove the 
empty interface and see what happens ?

    Thomas

On Tue, 9 Oct 2007, Alex Laudani - Softmasters wrote:

> Hello,
> I have problems with generating torque classes with torque generator.
> The generator is invoked using ant build from devaki nextobjects.
> Below are my schema.xml file and my build.properties.
> The generated BaseLibriPeer has the following problem:
> at line 825 it shows:
>
> boolean newObject = true;
>            for (int j = 0; j < results.size(); j++)
>            {
>                Libri temp_obj1 = (Libri)results.get(j);
>                Autori temp_obj2 = (Autori)temp_obj1.get();
>                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
>                {
>                    newObject = false;
>                    temp_obj2.addLibri(obj1);
>                    break;
>                }
>            }
>
> The problem is that
> Autori temp_obj2 = (Autori)temp_obj1.get();
> should be
> Autori temp_obj2 = (Autori)temp_obj1.getAutori();
> and so it gives an error at compile time because the get() method does not
> exist in Libri.
> I've tried to look at om/Peer.vm template and I can see the a
> $joinTable.Interface is involved. I think that the value for
> $table.Interface is not defined. How can I define it?
> Thank you
> Regards
>
> schema.xml
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <database name="" defaultIdMethod="native" defaultJavaType="primitive"
> package="org.devaki.nextobjects.models" baseClass="
> org.apache.torque.om.BaseObject" basePeer="org.apache.torque.util.BasePeer"
> defaultJavaNamingMethod="underscore" heavyIndexing="false">
>
>    <table name="autori" javaName="Autori" idMethod="null" baseClass="
> org.apache.torque.om.BaseObject" basePeer="org.apache.torque.util.BasePeer"
> interface="" javaNamingMethod="nochange" heavyIndexing="false"
> description="">
>
>        <column name="autore_id" javaName="autoreId" primaryKey="true"
> required="true" type="INTEGER" javaType="object"
> javaNamingMethod="javaname"/>
>        <column name="nome" javaName="nome" required="true" type="VARCHAR"
> javaType="object" size="255" javaNamingMethod="javaname"/>
>
>    </table>
>    <table name="libri" javaName="Libri" idMethod="null" baseClass="
> org.apache.torque.om.BaseObject" basePeer="org.apache.torque.util.BasePeer"
> interface="" javaNamingMethod="nochange" heavyIndexing="false"
> description="">
>
>        <column name="libro_id" javaName="libroId" primaryKey="true"
> required="true" type="INTEGER" javaType="object"
> javaNamingMethod="javaname"/>
>        <column name="titolo" javaName="titolo" type="VARCHAR"
> javaType="object" size="255" javaNamingMethod="javaname"/>
>        <column name="autore_id" javaName="autoreId" required="true"
> type="INTEGER" javaType="object" javaNamingMethod="javaname"/>
>
>        <foreign-key foreignTable="autori" onUpdate="none" onDelete="none">
>            <reference foreign="autore_id" local="autore_id"/>
>            <reference foreign="autore_id" local="autore_id"/>
>
>        </foreign-key>
>    </table>
> </database>
>
> build.properties:
> #--- properties for Torque build ---
> #Tue Oct 09 01:11:11 CEST 2007
> project=project1
> complexObjectModel=true
> databaseUrl=jdbc\:postgresql\://127.0.0.1/project1
> IntakeControlTemplate=intake/Control.vm
> ServiceControlTemplate=service/Control.vm
> torque.database.schema=public
> idTableControlTemplate=sql/id-table/Control.vm
> addSaveMethod=true
> createDatabaseUrl=jdbc\:postgresql\://127.0.0.1/template1
> basePrefix=Base
> addGetByNameMethod=true
> DataSQLControlTemplate=sql/load/Control.vm
> configDir=./config
> databaseHost=127.0.0.1
> databaseDriver=org.postgresql.Driver
> OMControlTemplate=om/Control.vm
> targetPackage=org.devaki.nextobjects.models
> database=postgresql
> documentationFormat=html
> DataDumpControlTemplate=data/dump/Control.vm
> DocControlTemplate=doc/Control.vm
> addIntakeRetrievable=true
> buildDatabaseUrl=jdbc\:postgresql\://127.0.0.1/project1
> DataDTDControlTemplate=data/Control.vm
> SQLControlTemplate=sql/base/Control.vm
> userManagers=false
> sameJavaName=false
> templatePath=templates
> torque.home=C\:\\Documents and Settings\\Alex\\devaki-nextobjects\\torque-
> gen-3.1
> databaseUser=devaki
> addTimeStamp=true
> outputDirectory=src
> databasePassword=
> schemaDirectory=schema
>

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