Okay, I got ambitious and made a few changes to the TorqueJDBCTransformTask
based on my discoveries. The diff below contains the following changes:
- The top-level element in the generated schema file is now <database
name="project"> instead of <app-data>.
- I added a few logging statements. This is basically laziness on my part:
I put them in while I was figuring this out, and perhaps someone else will
find them useful in their efforts.
Problems and notes:
I don't know whether other changes are necessary to make the schema file
conform to the Torque DTD, but I can now build the om classes without making
changes to the schema file.
The project name for the <database> tag is hardcoded to be "project". This
probably ought to be driven by a property, but I'm not the one to decide how
to set it up.
The generated schema file is still called src/schema.xml. It probably ought
to go into schema/myproject-schema.xml. Again, I'm not the one to make the
call on how that should happen.
-Thomas
------------------------------------------------------------------
112,113d111
< protected Node database, appData;
<
230,231c228,229
< appData = doc.createElement("app-data");
< database = doc.createElement("database");
---
> Element database = doc.createElement("database");
> database.setAttribute( "name", "project" );
236c234
< log("Building column/table map...");
---
> log("Building column/table map for " + tableList.size() + "
entries...");
374,375c372
< appData.appendChild(database);
< doc.appendChild(appData);
---
> doc.appendChild(database);
389c386
< log("Getting table list...");
---
> log("Getting table list: dbSchema=" + dbSchema + "...");
------------------------------------------------------------------
-----Original Message-----
From: Thomas Wheeler [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 5:57 PM
To: 'Turbine Torque Users List'
Subject: RE: templatePath
Great, thanks again Stephen. You're correct on all counts. I copied
src/schema.xml to schema/myproject-schema.xml, made a few minor changes
based on the example project-schema.xml, and the om target works great.
-Thomas
-----Original Message-----
From: Stephen Haberman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 4:19 PM
To: 'Turbine Torque Users List'
Subject: RE: templatePath
Hm...normally in the use of Torque, you have a naturally have a
project-schema.xml. I imagine the jdbc target generates to just
schema.xml as you wouldn't want it to overwrite your hand-created
schema.xml.
My guess is that since you'll probably only run the jdbc target once to
create the schema.xml and then hand-edit it for the rest of the project
(is there a reason you'll keep running the jdbc target), so renaming it
the first time to project-schema.xml shouldn't be a big deal.
I'm new to Torque development, but it looks like the jdbc task has not
been kept up to date on the format of the *-schema.xml. For now you'll
have to hack the jdbc output into the currently-accepted Torque DTD. It
shouldn't be too bad.
- Stephen
> -----Original Message-----
> From: Thomas Wheeler [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 23, 2002 2:19 PM
> To: 'Turbine Torque Users List'
> Subject: RE: templatePath
>
> Thanks for the patch, I'll put that into my build.
>
> Now I'm stuck again. <aside type="rant">I'm not laying blame or
passing
> judgment since I'm using a beta, but gosh it's frustrating using a
product
> with outdated documentation!</aside>
>
> Anyway. I've used the jdbc target to create a src/schema.xml from my
> existing database metadata. And I'm able to generate an SQL schema
from it
> (src/sql/* files). Now I want to generate the om target. This
expects to
> work from a schema/*-schema.xml. Okay, fine. So the question is, how
do I
> generate a schema/*-schema.xml from my src/schema.xml? There doesn't
appear
> to be a target that does this, and the extremely-naive approach of
copying
> src/schema.xml to schema/myproject-schema.xml blows up. Help...?
>
> -Thomas
>
> -----Original Message-----
> From: Stephen Haberman [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 23, 2002 11:38 AM
> To: 'Turbine Torque Users List'
> Subject: RE: templatePath
>
>
> Hm...good job of tracking that down.
>
> I've got a patch into velocity-dev that will let us get around this
> thorny template/useClasspath issue but until then, I'll submit a patch
> to handle this.
>
> Actually, now that I look, I've got a larger patch for
build-torque.xml
> that fixes this issue. I'm waiting for commit access to put it in the
> repository, but if you want, the approach I take in the patch is:
>
> Use ant's condition task like:
>
> <target name="check-use-classpath">
> <condition property="torque.internal.useClasspath">
> <equals arg1="${useClasspath}" arg2="true"/>
> </condition>
> </target>
>
> Then change the target sql-template/sql-classpath targets by adding a
> dependents="check-use-classpath" and change the if/unless from just
> useClasspath to torque.internal.useClasspath which will only be set
> ifuseClasspath is true.
>
> - Stephen
>
> > -----Original Message-----
> > From: Thomas Wheeler [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, July 23, 2002 11:29 AM
> > To: 'Turbine Torque Users List'
> > Subject: RE: templatePath
> >
> > Solution found. Developers, I hope you're listening. (msegalla, I
> hope
> > you're listening too :).)
> >
> > The "sql-classpath" target was being built instead of
"sql-template".
> > Apparently, if sql-template is to be built, the useClassPath
property
> must
> > be undefined (not just set to false) -- otherwise it will use the
> > sql-classpath target.
> >
> > According to the Ant documentation, using "if" in a <target>
executes
> the
> > target if the property is set, regardless of the value it is set to.
> So the
> > target
> >
> > <target name="sql-classpath" if="useClasspath">
> >
> > executes if useClasspath is set _at all_. A brief scan of the docs
> doesn't
> > describe this behavior.
> >
> > -Thomas
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail: <mailto:turbine-torque-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:turbine-torque-user-
> [EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>