Jason,

>If you change your xml schema for your project than you must
>also regenerate the sql. If you take a peek at the build.xml
>you will see what targets are available to you.

>There are a set of targets run against myapp-schema.xml, look
>at the 'init' target and you will see the following that the following
>targets are run for a project specifically:

>project-sql
>project-id-table-init-sql
>project-insert-sql
>project-om

That's exactly what I thought when I had a deeper look into the build.xml
file.
My problem with that is that then my tables get droped and created again,
i.e. I loose all data in them.


>When this is done you need to compile the regenerated classes.

>Try adding the following to your build.xml file:

><target name="project"
>  description="--> regenerates project specific resources after a change to
>                   your project xml schema">

>  <antcall target="project-sql">
>  <antcall target="project-id-table-init-sql">
>  <antcall target="project-insert-sql">
>  <antcall target="project-om">
>  <antcall target="compile">

></target>

>I have not tested this, but I will add this target to the TDK now so
>that it is easier to propagate changes resulting from an edited
>project xml schema.

>Let me know if this works, I'll fix it up if it's not working
>for you.

Even so that I do loose my table data I've tried that:

Situation: I built a brand new application (ant in tdk root dir): MYAPP.
A database myapp was automatically created in the normal way.
The only change I made was that in the myapp-schema.xml I added
2 more tables (no foreign keys, just table defintions).
Everything was generated just fine and I got the servlet running.

Then I changed my myapp-schema.xml in the way that in one of the 3 tables in
there
I added a foreign key tag:

        <database>
                 <table name="RDF">
                        <column name="RDF_ID" required="true"
autoIncrement="true" primaryKey="true" type="INTEGER"/>
                        <column name="TITLE" size="255" type="VARCHAR"/>
                        <column name="BODY" size="255" type="VARCHAR"/>
                        <column name="URL" size="255" type="VARCHAR"/>
                        <column name="AUTHOR" size="255" type="VARCHAR"/>
                        <column name="DEPT" size="255" type="VARCHAR"/>
                 </table>
                <table name="DATEN">
                        <column name="DATEN_ID" required="true"
autoIncrement="true" primaryKey="true" type="INTEGER"/>
                        <column name="VORNAME" size="255" type="VARCHAR"/>
                        <column name="NACHNAME" size="255" type="VARCHAR"/>
                        <column name="ORT" size="255" type="VARCHAR"/>
                        <column name="TELEFON" size="255" type="VARCHAR"/>
                        <column name="EMAIL" size="255" type="VARCHAR"/>
                 </table>
                <table name="BUCH">
                        <column name="BUCH_ID" required="true"
autoIncrement="true" primaryKey="true" type="INTEGER"/>
                        <column name="AUTOR" size="100" type="VARCHAR"/>
                        <column name="TITEL" size="50" type="VARCHAR"/>
                        <column name="MENGE" type="INTEGER"/>
                        <foreign-key foreign-table="DATEN">
                                <reference foreign="DATEN_ID"
local="BUCH_ID"/>
                        </foreign-key>
                 </table>
        </database>

When I then run
ant project
it comes with an error (in the project-om part):
        
        project-om:
     [echo] +------------------------------------------+
     [echo] |                                          |
     [echo] | Generating Peer-based Object Model for   |
     [echo] | YOUR Turbine project! Woo hoo!           |
     [echo] |                                          |
     [echo] +------------------------------------------+
C:\tdk\webapps\myapp\WEB-INF\src\java\report.myapp.om.generation
java.lang.NullPointerException
        at java.util.Hashtable.get(Hashtable.java:320)
        at
org.apache.turbine.torque.engine.database.model.Database.getTable(Database.j
ava:216)
        at
org.apache.turbine.torque.engine.database.transform.XmlToAppData.startElemen
t(XmlToAppData.java:224)
        at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:1122)
        at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1858)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1234)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
        at
org.apache.turbine.torque.engine.database.transform.XmlToAppData.parseFile(X
mlToAppData.java:152)
        at
org.apache.turbine.torque.TorqueObjectModelTask.initControlContext(TorqueObj
ectModelTask.java:148)
        at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:124)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:213)
        at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:103)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at org.apache.tools.ant.Main.runBuild(Main.java:421)
        at org.apache.tools.ant.Main.main(Main.java:149)
java.lang.NullPointerException
        at
org.apache.turbine.torque.engine.database.transform.XmlToAppData.startElemen
t(XmlToAppData.java:237)
        at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:1122)
        at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1858)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1234)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
        at
org.apache.turbine.torque.engine.database.transform.XmlToAppData.parseFile(X
mlToAppData.java:152)
        at
org.apache.turbine.torque.TorqueObjectModelTask.initControlContext(TorqueObj
ectModelTask.java:148)
        at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:124)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:213)
        at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:103)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at org.apache.tools.ant.Main.runBuild(Main.java:421)
        at org.apache.tools.ant.Main.main(Main.java:149)

BUILD FAILED

C:\tdk\webapps\myapp\WEB-INF\build\build.xml:178: Exception thrown by
'generator.parse'. For more information consu
ty log.
--- Nested Exception ---
org.apache.velocity.exception.MethodInvocationException: Invocation of
method 'isMultipleFK' in  class org.apache.t
.engine.database.model.Column threw exception class
java.lang.NullPointerException
        at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java)
        at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.ja
va)
        at
org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReference.j
ava)
        at
org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression
.java)
        at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
.java)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
        at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav
a)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
.java)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
        at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav
a)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
.java)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
.java)
        at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
        at org.apache.velocity.Template.merge(Template.java)
        at org.apache.velocity.texen.Generator.parse(Generator.java)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java)
        at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.ja
va)
        at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.jav
a)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
        at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav
a)
        at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
        at
org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
        at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav
a)
        at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
        at org.apache.velocity.Template.merge(Template.java)
        at org.apache.velocity.texen.Generator.parse(Generator.java)
        at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:124)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:213)
        at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:103)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at org.apache.tools.ant.Main.runBuild(Main.java:421)
        at org.apache.tools.ant.Main.main(Main.java:149)

Next I tried to simple add one new table to my myapp-schema.xml (no foreign
keys)
and run
ant project
that works fine BUT you have to delete all JAVA  files in directory .../om
before;
if not 'compile' will bring a hell of a  lot of compilation errors.

Actually the foreign key defintion in order to get the doSelctJoinTableX
method
is only one of my problems;
I have to develop a commercial application.
But in our project, the database already exists (and unfortunately also
changes occasionally).
Even so that we can't use the database and table creation mechanism from the
build file,
because they already exist, can we still use Torque somehow to generate all
the Peer files?

Britta

-- 

jvz.

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

<<attachment: winmail.dat>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to