From brookschristopher@example.org Sat Mar 1 17:03:49 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 99236 invoked from network); 1 Mar 2003 17:03:49 -0000 Received: from zebra.zinkwazi.com (83.161.120.155) by daedalus.apache.org with SMTP; 1 Mar 2003 17:03:49 -0000 Received: (from dallen@localhost) by zebra.zinkwazi.com (8.11.6/8.11.6) id h21H3qg31587 for brookschristopher@example.org; Sat, 1 Mar 2003 11:03:52 -0600 Date: Sat, 1 Mar 2003 11:03:52 -0600 From: Dan Allen <brookschristopher@example.org> To: brookschristopher@example.org Subject: Database.java source code bug Message-ID: <brookschristopher@example.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/83.161.120.155i X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I encountered an error when running ant -f build-torque.xml only to discover a NullPointerException in Database.java:468. Upon futhur research, I discovered the following, blatantly obvious bug in the sourcecode when reporting a foreign key error around line 466. org.apache.torque.engine.database.model.Database.doFinalInitialization if (foreign == null) { System.out.println("ERROR!! Attempt to set foreign" + " key to nonexistent column, " + foreign.getName() + ", in table, " + foreignTable.getName() + "!"); } foreign.getName() will throw a null pointer if it is in fact null...not a good debugging routine there. Dan -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Daniel Allen, <brookschristopher@example.org> http://www.mojavelinux.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hey, somebody, sometime, somewhere, said something I think that just maybe might have been true but I think that I maybe didn't like it. F^CK IT, I'm suing everybody. -- slashdot member in response to petswarehouse.com sueing google.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From brookschristopher@example.org Mon Mar 3 08:54:00 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 36033 invoked from network); 3 Mar 2003 08:54:00 -0000 Received: from mail.informex.net (HELO voland.informex.net) (83.161.120.155) by daedalus.apache.org with SMTP; 3 Mar 2003 08:54:00 -0000 Received: from pluto ([83.161.120.155]) by voland.informex.net (8.12.6/8.12.6) with ESMTP id h238s0fd081444 for <brookschristopher@example.org>; Mon, 3 Mar 2003 10:54:01 +0200 (EET) (envelope-from brookschristopher@example.org) From: "Alexander Fedorenko" <brookschristopher@example.org> To: <brookschristopher@example.org> Subject: Error using ant task with Torque Date: Mon, 3 Mar 2003 10:47:27 +0200 Message-ID: <000901c2e161$85d4ac60$6e05a8c0@pluto> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello. I discovered strange problem. The software used is ant-1.5.1, j2sdk1.4.1 . It does not appear using jsdk 1.3.1 , only 1.4.1 . When I execute Ant task 'java' , I got error : populate: [java] java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl Ant task is : <target name="populate" description="populare db data "> <java classname="module.jate.Setup" fork="false"> <arg value="${deploy.home}/WEB-INF/classes/Torque.properties"/> <classpath> <path refid="compile.classpath"/> <pathelement location="${deploy.home}/WEB-INF/classes"/> </classpath> </java> </target> and source file is : package module.jate; import java.util.*; import java.sql.*; import org.apache.torque.Torque; public class Setup { public static void main(String args[]) { try { if ( args.length == 0 ) { System.out.println("No properties file path was specified."); return ; } Torque.init( args[0] ); Torque.shutdown(); } catch (Exception e) { e.printStackTrace(System.err); } } } From brookschristopher@example.org Mon Mar 3 16:52:51 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 63347 invoked from network); 3 Mar 2003 16:52:51 -0000 Received: from www3.kc.aoindustries.com (83.161.120.155) by daedalus.apache.org with SMTP; 3 Mar 2003 16:52:51 -0000 Received: from ericemminger.com (163-44.9-67.se.rr.com [83.161.120.155] (may be forged)) (authenticated) by www3.kc.aoindustries.com (8.11.6/8.11.6) with ESMTP id h23GpvJ03119; Mon, 3 Mar 2003 10:51:57 -0600 Message-ID: <brookschristopher@example.org> Date: Mon, 03 Mar 2003 11:51:40 -0500 From: Eric Emminger <brookschristopher@example.org> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Turbine Torque Developers List <brookschristopher@example.org> CC: brookschristopher@example.org Subject: Re: Database.java source code bug References: <brookschristopher@example.org> In-Reply-To: <brookschristopher@example.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Dan Thanks for finding this! If you'd like, you could create a patch and contribute it to the Torque project! Help is always welcome! Eric Dan Allen wrote: > I encountered an error when running > > ant -f build-torque.xml > > only to discover a NullPointerException in Database.java:468. Upon > futhur research, I discovered the following, blatantly obvious bug > in the sourcecode when reporting a foreign key error around line 466. > > org.apache.torque.engine.database.model.Database.doFinalInitialization > > if (foreign == null) > { > System.out.println("ERROR!! Attempt to set foreign" > + " key to nonexistent column, " > + foreign.getName() + ", in table, " > + foreignTable.getName() + "!"); > } > > foreign.getName() will throw a null pointer if it is in fact > null...not a good debugging routine there. > > Dan > From brookschristopher@example.org Tue Mar 4 16:50:08 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 5113 invoked from network); 4 Mar 2003 16:50:08 -0000 Received: from pd9e94917.dip0.t-ipconnect.de (HELO muku.x-root.de) (83.161.120.155) by daedalus.apache.org with SMTP; 4 Mar 2003 16:50:08 -0000 Received: by MUKU with Internet Mail Service (5.5.2448.0) id <F4AMCXTJ>; Tue, 4 Mar 2003 17:51:58 +0100 Message-ID: <319491337EE1D41199CF00600820655307502E@MUKU> From: Martin Nattrodt <brookschristopher@example.org> To: Turbine Torque Developers List <brookschristopher@example.org> Cc: "'brookschristopher@example.org'" <brookschristopher@example.org> Subject: AW: Configuration for different databases Date: Tue, 4 Mar 2003 17:51:51 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello, I want just describe what I am doing: We want to prepare different Database for our software. So we need some = SQL Statements for different databases.=20 First we extract the schema from the database (ant -f build-torque.xml jdbc). Then I want to create statements for different databases. Today I started to extract data and create SQL statements for the data. There are two problems: The one I described already (different databases needs different properties). The other is, that the source and target names are not always the same = in build-torque.xml. I did the following sequence: ant -f build-torque.xml jdbc # Then you have to rename schema.xml to YOURSCHEMA-schema.xml ant -f build-torque.xml datadump # Copy the data xml file from src/ to schema/ and rename it # Change the build.properties for your target database.=20 # If necessary edit sqldb.map ant -f build-torque.xml sql ant -f build-torque.xml insert-sql At first time it was a little bit hard to get around with torque. At = the moment I use some scripts to do the work around. But I am looking for a = easy way.=20 I think the best way is to modify the build-torque.xml file that all databases get there own target dir. Something like: mysql +- src +- schema +- .. db2 +- src +- schema +- .. Martin > -----Urspr=FCngliche Nachricht----- > Von: Eric Emminger [mailto:brookschristopher@example.org] > Gesendet: Dienstag, 4. M=E4rz 2003 16:06 > An: Turbine Torque Users List > Betreff: Re: Configuration for different databases >=20 >=20 > Thank you, Howard, for informing me! :) >=20 > You could request this as a new feature if you want. >=20 > Thanks again. >=20 > Eric >=20 > Howard Lin wrote: > > Torque run time supports multiple database configuration=20 > but not at "generation" time. Here is the quote from that tutorial: > > "It is worth re-iterating that these run-time properties=20 > are not used by Torque when generating your object model and=20 > creating your database. They are used only by the application=20 > utilizing the Torque-generated object model brookschristopher@example.org." >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: brookschristopher@example.org > For additional commands, e-mail: brookschristopher@example.org >=20 From brookschristopher@example.org Tue Mar 11 19:47:47 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 50754 invoked from network); 11 Mar 2003 19:47:47 -0000 Received: from unknown (HELO mail2.concurtech.net) (83.161.120.155) by daedalus.apache.org with SMTP; 11 Mar 2003 19:47:47 -0000 Received: by gemini with Internet Mail Service (5.5.2653.19) id <10LBDH6C>; Tue, 11 Mar 2003 11:52:52 -0800 Message-ID: <29D64E0297B6D4118F14009027B8D45701DBBD2D@gemini> From: Walt Armour <brookschristopher@example.org> To: Torque Dev <brookschristopher@example.org> Subject: UPDATE and criteria across multiple tables Date: Tue, 11 Mar 2003 11:52:51 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I'm looking at implementing a patch for the hugely inefficient way Torque does updates and deletes (this has been discussed previously on the list and a patch against an older Torque was posted by brookschristopher@example.org). I've found something that I consider highly odd in the code and was hoping someone could tell me the reasoning behind it (otherwise it's getting yanked). In BasePeer.doUpdate() it builds up a list of tables and loops, performing a select/update cycle for each table mentioned in the select criteria (not the update values criteria). Looking at the way the code is implemented it appears that if anyone actually used this functionality they could really hurt themselves. A SQL update can only affect one table. However, the where clause can reference multiple tables but there still would only be a single table updated. So, boils down to this: why is this functionality in there? I can't think of any valid way to use it from a criteria standpoint nor can I think of a valid SQL equivalent that would yield updates to multiple tables with a single statement. From brookschristopher@example.org Wed Mar 12 16:29:11 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 97718 invoked from network); 12 Mar 2003 16:29:11 -0000 Received: from pd9e9484e.dip0.t-ipconnect.de (HELO muku.x-root.de) (83.161.120.155) by daedalus.apache.org with SMTP; 12 Mar 2003 16:29:11 -0000 Received: by MUKU with Internet Mail Service (5.5.2448.0) id <F4AMCYG4>; Wed, 12 Mar 2003 17:31:06 +0100 Message-ID: <319491337EE1D41199CF006008206553075035@MUKU> From: Martin Nattrodt <brookschristopher@example.org> To: "Turbine Torque Developers List (E-Mail)" <brookschristopher@example.org> Subject: Software Development Date: Wed, 12 Mar 2003 17:31:05 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello, I am new to open source projects. I found Torque very useful. But some thing did not work like expected, so I did some changes on some files locally. Something I changed might be useful. So what is the best way to integrate this changes? I don't want to destroy anything with my changes. Regards Martin. From brookschristopher@example.org Wed Mar 12 20:30:58 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 901 invoked from network); 12 Mar 2003 20:30:58 -0000 Received: from www3.kc.aoindustries.com (83.161.120.155) by daedalus.apache.org with SMTP; 12 Mar 2003 20:30:58 -0000 Received: from ericemminger.com (163-44.9-67.se.rr.com [83.161.120.155] (may be forged)) (authenticated) by www3.kc.aoindustries.com (8.11.6/8.11.6) with ESMTP id h2CKV3Y03685 for <brookschristopher@example.org>; Wed, 12 Mar 2003 14:31:03 -0600 Message-ID: <brookschristopher@example.org> Date: Wed, 12 Mar 2003 15:30:58 -0500 From: Eric Emminger <brookschristopher@example.org> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Turbine Torque Developers List <brookschristopher@example.org> Subject: Re: Software Development References: <319491337EE1D41199CF006008206553075035@MUKU> In-Reply-To: <319491337EE1D41199CF006008206553075035@MUKU> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Martin Basically, you submit a patch on the issue tracking system. See these articles. http://jakarta.apache.org/site/getinvolved.html http://jakarta.apache.org/turbine/common/code-standards.html Eric Martin Nattrodt wrote: > Hello, > > I am new to open source projects. I found Torque very useful. But some thing > did not work like expected, so I did some changes on some files locally. > Something I changed might be useful. > So what is the best way to integrate this changes? I don't want to destroy > anything with my changes. > > Regards Martin. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: brookschristopher@example.org > For additional commands, e-mail: brookschristopher@example.org > From brookschristopher@example.org Thu Mar 13 10:15:20 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 94767 invoked from network); 13 Mar 2003 10:15:20 -0000 Received: from mail6.home.nl (HELO mail6-sh.home.nl) (83.161.120.155) by daedalus.apache.org with SMTP; 13 Mar 2003 10:15:20 -0000 Received: from Sauron ([83.161.120.155]) by mail6-sh.home.nl (InterMail vM.83.161.120.155 201-253-122-126-117-20021021) with ESMTP id <20030313101533.ORRU21331.mail6-sh.home.nl@Sauron> for <brookschristopher@example.org>; Thu, 13 Mar 2003 11:15:33 +0100 From: "Age Mooy" <brookschristopher@example.org> To: <brookschristopher@example.org> Subject: Torque as an Avalon component ? Date: Thu, 13 Mar 2003 11:17:27 +0100 Message-ID: <brookschristopher@example.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I would like to start converting Torque to Avalon. I know this topic has been discussed before on torque-dev and turbine-dev, but I don't think any conclusions have been reached. Is anyone working on this ? As I see it, there are three basic options for making Torque compatible with Avalon: 1) Write a simple component wrapper around Torque that takes care of configuration and initialization and delegates all method calls to the static Torque class. 2) Redesign the current Torque class into a "real" avalon component implementation, getting rid of all static methods and Stratum interfaces. This would severely break backwards compatibility and would need a lot of work, esspecially on the whole concept of static Peer classes, because then Torque can only be accessed with the aid of an Avalon ServiceManager/ServiceSelector 3) Combine 1) and 2) by doing a full implementation not named Torque.java and making the Torque class a simple static wrapper that ensures backwards compatibility. The problems mentioned for option 2 still apply here though. Option 3 would keep the most people happy I guess. But option 2 and 3 require a lot of discussion about the use of static methods and static Peer classes in Torque, not to mention a lot of work. One of the biggest questions is: how would client code that doesn't have access to an Avalon ServiceManager get access to Torque ? Maybe we could write a very simple Avalon container What do you all think ? I have time to implement at least option 1 and I need some way to load torque as a component anyway, so I volunteer for that. This is what I propose: - a TorqueService interface with non-static versions of the relevant methods in the Torque class - a DefaultTorqueService class that implements the Avalon lifecycle interfaces, and delegates everything to the Torque class Would this be acceptable ? Should this go in the org.apache.torque package or in a sub-package ? Regards, Age From brookschristopher@example.org Thu Mar 13 16:26:17 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 40472 invoked from network); 13 Mar 2003 16:26:17 -0000 Received: from mail.bynum.com (HELO blr02.bynum.com) (83.161.120.155) by daedalus.apache.org with SMTP; 13 Mar 2003 16:26:17 -0000 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Importance: normal Priority: normal Content-Transfer-Encoding: quoted-printable Subject: RE: Torque as an Avalon component ? X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Date: Thu, 13 Mar 2003 10:25:53 -0600 Message-ID: <brookschristopher@example.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Torque as an Avalon component ? Thread-Index: AcLpSXAvRAVixItCTnu0YVzoNnAyaQAMKgwQ From: "Quinton McCombs" <brookschristopher@example.org> To: "Turbine Torque Developers List" <brookschristopher@example.org> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N > -----Original Message----- > From: Age Mooy [mailto:brookschristopher@example.org]=20 > Sent: Thursday, March 13, 2003 4:17 AM > To: brookschristopher@example.org > Subject: Torque as an Avalon component ? >=20 >=20 > Hi, >=20 > I would like to start converting Torque to Avalon. I know=20 > this topic has been discussed before on torque-dev and=20 > turbine-dev, but I don't think any conclusions have been=20 > reached. Is anyone working on this ? I was but I have not had time to finish it. Trying to keep full backwards compatibility made it a more involved task than I had originally expected. =20 > As I see it, there are three basic options for making Torque=20 > compatible with Avalon: >=20 > 1) > Write a simple component wrapper around Torque that takes=20 > care of configuration and initialization and delegates all=20 > method calls to the static Torque class. >=20 > 2) > Redesign the current Torque class into a "real" avalon=20 > component implementation, getting rid of all static methods=20 > and Stratum interfaces. This would severely break backwards=20 > compatibility and would need a lot of work, esspecially on=20 > the whole concept of static Peer classes, because then Torque=20 > can only be accessed with the aid of an Avalon=20 > ServiceManager/ServiceSelector >=20 > 3) > Combine 1) and 2) by doing a full implementation not named=20 > Torque.java and making the Torque class a simple static=20 > wrapper that ensures backwards compatibility. The problems=20 > mentioned for option 2 still apply here though. >=20 > Option 3 would keep the most people happy I guess. But option=20 > 2 and 3 require a lot of discussion about the use of static=20 > methods and static Peer classes in Torque, not to mention a=20 > lot of work. One of the biggest questions is: how would=20 > client code that doesn't have access to an Avalon=20 > ServiceManager get access to Torque ? Maybe we could write a=20 > very simple Avalon container You would need one additional class to function as a simple container for Torque when used standalone. > What do you all think ? >=20 > I have time to implement at least option 1 and I need some=20 > way to load torque as a component anyway, so I volunteer for=20 > that. This is what I > propose: >=20 > - a TorqueService interface with non-static versions of the=20 > relevant methods in the Torque class > - a DefaultTorqueService class that implements the Avalon=20 > lifecycle interfaces, and delegates everything to the Torque class >=20 > Would this be acceptable ? Should this go in the=20 > org.apache.torque package or in a sub-package ? TorqueService would go in org.apache.torque. DefaultTorqueService would typically go in a sub-package. I don't think that it really matter right now though. I would say get it working and then look at how things fall out. I would be happy to assist with this. >=20 > Regards, > Age >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: brookschristopher@example.org > For additional commands, e-mail: brookschristopher@example.org >=20 >=20 From brookschristopher@example.org Fri Mar 14 23:41:39 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 67497 invoked from network); 14 Mar 2003 23:41:39 -0000 Received: from unknown (HELO mail2.concurtech.net) (83.161.120.155) by daedalus.apache.org with SMTP; 14 Mar 2003 23:41:39 -0000 Received: by gemini with Internet Mail Service (5.5.2653.19) id <10LB1JK3>; Fri, 14 Mar 2003 15:46:49 -0800 Message-ID: <29D64E0297B6D4118F14009027B8D45701DBBD67@gemini> From: Walt Armour <brookschristopher@example.org> To: 'Turbine Torque Developers List' <brookschristopher@example.org> Subject: Torque Object type to SQL type mapping Date: Fri, 14 Mar 2003 15:46:47 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Someone tell me if I'm just missing this... I can't find anywhere in Torque that maps from a 'type object' to a java.sql.Types type. When I say 'type object' I mean the way that Torque uses empty instances of Java objects to signify column types. I've looked through TypeMap.java and I'm not sure where else it would be hiding. If there isn't one then I would like to add one to TypeMap.java (probably using the class object for the key). I'm aware there are a few (2?) 1-to-many maps this way but I would just boil it down to 1-1 (Java String -> VARCHAR, not CHAR or LONGVARCHAR). Any comments before I put this in? From brookschristopher@example.org Wed Mar 19 02:36:50 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 76898 invoked from network); 19 Mar 2003 02:36:50 -0000 Received: from lists.demandsolutions.com (HELO mail.demandsolutions.com) (83.161.120.155) by daedalus.apache.org with SMTP; 19 Mar 2003 02:36:50 -0000 Received: (qmail 6276 invoked by uid 304); 19 Mar 2003 02:36:58 -0000 Received: from brookschristopher@example.org by dmi-qmail by uid 301 with qmail-scanner-1.10 (uvscan: v4.1.60/v4100. . Clear:0. Processed in 0.599049 secs); 19 Mar 2003 02:36:58 -0000 Received: from unknown (HELO cgreenlee) (83.161.120.155) by dmi-qmail.demandsolutions.com with SMTP; 19 Mar 2003 02:36:58 -0000 Received: from 83.161.120.155 (SquirrelMail authenticated user DMI_AD/cgreenlee) by asmara.demandsolutions.com with HTTP; Tue, 18 Mar 2003 20:36:58 -0600 (CST) Message-ID: <brookschristopher@example.org> Date: Tue, 18 Mar 2003 20:36:58 -0600 (CST) Subject: Precision, scale, and index tablespaces. From: "Chris Greenlee" <brookschristopher@example.org> To: <brookschristopher@example.org> X-Priority: 3 Importance: Normal Reply-To: brookschristopher@example.org X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_20030318203658_49646" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_20030318203658_49646 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello all, we've been using Torque for a while to generate SQL based on our OJB repository. We've had to tweak a few things to get them to work though, and we thought we should contribute them back. 1. When generating DECIMAL columns, we needed to generate precision and scale. 2. When generating indexes, we needed (at least on Oracle) to be able to specify the tablespace for the index. It's a huge performance boost to have the index located on a separate drive from the table. 3. We use non-native auto incrementing heavily, and needed to be able to turn it off. Although Table has an Id Method, it wasn't being checked in the velocity macros. We needed to enable that. 4. There were some weird end of file characters in some of the velocity templates that caused SQL generation to die a horrible death under Windows. Attached is a patch that addresses all these issues. Here's a short list of the affected files: src/generator/src/dtd/database.dtd src/generator/src/java/org/apache/torque/engine/database/model/Column.java src/generator/src/java/org/apache/torque/engine/database/model/Table.java src/generator/src/templates/sql/base/mssql/columns.vm src/generator/src/templates/sql/base/mssql/db.props src/generator/src/templates/sql/base/oracle/columns.vm src/generator/src/templates/sql/base/oracle/db.props src/generator/src/templates/sql/base/oracle/index.vm src/generator/src/templates/sql/base/oracle/primarykey.vm src/generator/src/templates/sql/base/oracle/unique.vm src/generator/src/templates/sql/base/postgresql/columns.vm src/generator/src/templates/sql/base/postgresql/db.props src/generator/src/templates/sql/base/postgresql/index.vm src/generator/src/templates/sql/base/postgresql/table.vm We've only modified Oracle, PostgreSQL, and MS SQL velocity macros because those are the only databases we've been hitting. As we add more, we'll be glad to submit those changes back as well. If you have any questions, I'd be glad to answer them. We're eager to get the changes into Torque so that we don't have to maintain a separate local version. Regards, Chris Greenlee ------=_20030318203658_49646 Content-Type: text/plain; name="patch.txt" Content-Disposition: attachment; filename="patch.txt" Index: src/generator/src/dtd/database.dtd =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/dtd/database.dtd,v retrieving revision 1.1 diff -u -r1.1 database.dtd --- src/generator/src/dtd/database.dtd 10 Feb 2003 13:22:37 -0000 1.1 +++ src/generator/src/dtd/database.dtd 19 Mar 2003 02:26:07 -0000 @@ -66,6 +66,7 @@ javaNamingMethod (nochange|underscore|javaname) #IMPLIED heavyIndexing (true|false) #IMPLIED description CDATA #IMPLIED + indexTablespace CDATA #IMPLIED > <!ELEMENT id-method-parameter EMPTY> @@ -91,6 +92,8 @@ ) "VARCHAR" javaType (object|primitive) #IMPLIED size CDATA #IMPLIED + precision CDATA #IMPLIED + scale CDATA #IMPLIED default CDATA #IMPLIED autoIncrement (true|false) "false" inheritance (single|false) "false" Index: src/generator/src/java/org/apache/torque/engine/database/model/Column.java =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v retrieving revision 1.1 diff -u -r1.1 Column.java --- src/generator/src/java/org/apache/torque/engine/database/model/Column.java 10 Feb 2003 13:20:58 -0000 1.1 +++ src/generator/src/java/org/apache/torque/engine/database/model/Column.java 19 Mar 2003 02:26:09 -0000 @@ -81,6 +81,9 @@ private String javaNamingMethod; private boolean isNotNull = false; private String size; + private String precision; + private String scale; + /** type as defined in schema.xml */ private String torqueType; private String javaType; @@ -198,6 +201,8 @@ defaultValue = attrib.getValue("default"); size = attrib.getValue("size"); + precision = attrib.getValue("precision"); + scale = attrib.getValue("scale"); setType(attrib.getValue("type")); @@ -638,6 +643,42 @@ public void setSize(String newSize) { size = newSize; + } + + /** + * Returns the precision for this column. + * @return The precision for this column. + */ + public String getPrecision() + { + return precision; + } + + /** + * Sets the precision for this column. + * @param precision The precision for this column. + */ + public void setPrecision(String precision) + { + this.precision = precision; + } + + /** + * Returns the scale for this column. + * @return The scale for this column. + */ + public String getScale() + { + return scale; + } + + /** + * Sets the scale for this column. + * @param scale The scale for this column. + */ + public void setScale(String scale) + { + this.scale = scale; } /** Index: src/generator/src/java/org/apache/torque/engine/database/model/Table.java =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Table.java,v retrieving revision 1.1 diff -u -r1.1 Table.java --- src/generator/src/java/org/apache/torque/engine/database/model/Table.java 10 Feb 2003 13:20:58 -0000 1.1 +++ src/generator/src/java/org/apache/torque/engine/database/model/Table.java 19 Mar 2003 02:26:11 -0000 @@ -89,6 +89,7 @@ private String javaName; private String idMethod; private String javaNamingMethod; + private String indexTablespace; private Database tableParent; private List referrers; private List foreignTableNames; @@ -144,6 +145,11 @@ javaName = attrib.getValue("javaName"); idMethod = attrib.getValue("idMethod"); + String indexTablespace = attrib.getValue("indexTablespace"); + if (indexTablespace != null && indexTablespace.trim().length() > 0) { + setIndexTablespace(indexTablespace.trim()); + } + // retrieves the method for converting from specified name to // a java name. javaNamingMethod = attrib.getValue("javaNamingMethod"); @@ -1029,6 +1035,22 @@ public void setForReferenceOnly(boolean v) { this.forReferenceOnly = v; + } + + /** + * The name of the tablespace to create indexes on, if the database supports them. + * @return The name of the tablespace to create the index on. + */ + public String getIndexTablespace() { + return indexTablespace; + } + + /** + * Sets the name of the tablespace to create the index on. + * @param indexTablespace The name of the index tablespace. + */ + public void setIndexTablespace(String indexTablespace) { + this.indexTablespace = indexTablespace; } /** Index: src/generator/src/templates/sql/base/mssql/columns.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/mssql/columns.vm,v retrieving revision 1.1 diff -u -r1.1 columns.vm --- src/generator/src/templates/sql/base/mssql/columns.vm 10 Feb 2003 13:18:49 -0000 1.1 +++ src/generator/src/templates/sql/base/mssql/columns.vm 19 Mar 2003 02:26:11 -0000 @@ -1,14 +1,23 @@ #foreach ($col in $table.Columns) #set ( $type = $dbprops.get($col.Type) ) - #if ($type == "INT" || $type == "TEXT") + #if ($type == "DECIMAL") + #set ( $type = "$type ($col.precision,$col.scale)") + #end + #if ($type == "INT" || $type == "TEXT" || $type == "DECIMAL") #set ( $size = "" ) - #else + #else #set ( $size = $col.printSize() ) #end #set ( $default = $col.DefaultSetting ) #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),$dbprops.get("NULL")) ) - #set ( $autoIncrement = $strings.select($col.isAutoIncrement(), $dbprops.get("AUTOINCREMENT"),"") ) - #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," ) + #if ($col.isAutoIncrement() && $table.IdMethod == "native") + #set ( $autoIncrement = $strings.select($col.isAutoIncrement(), $dbprops.get("AUTOINCREMENT"),"") ) + #else + #set ( $autoIncrement = " " ) + #end + #set ( $entry = "$col.Name $type " ) + #if ($type != "INT") #set ( $entry = "$entry $size" )#end + #set ( $entry = "$entry $default $nullString $autoIncrement," ) $strings.sub($strings.collapseSpaces($entry)," ,",",") #end Index: src/generator/src/templates/sql/base/mssql/db.props =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/mssql/db.props,v retrieving revision 1.1 diff -u -r1.1 db.props --- src/generator/src/templates/sql/base/mssql/db.props 10 Feb 2003 13:18:49 -0000 1.1 +++ src/generator/src/templates/sql/base/mssql/db.props 19 Mar 2003 02:26:11 -0000 @@ -2,19 +2,19 @@ TINYINT = TINYINT SMALLINT = SMALLINT INTEGER = INT -BIGINT = BIGINT +BIGINT = INT FLOAT = FLOAT REAL = REAL -DOUBLE = FLOAT +DOUBLE = DECIMAL NUMERIC = NUMERIC DECIMAL = DECIMAL -CHAR = CHAR +CHAR = VARCHAR VARCHAR = VARCHAR LONGVARCHAR = TEXT DATE = DATETIME TIME = DATETIME TIMESTAMP = DATETIME -BINARY = BINARY(7132) +BINARY = BINARY VARBINARY = IMAGE LONGVARBINARY = IMAGE NULL = NULL @@ -31,5 +31,5 @@ NOTNULL = NOT NULL removeNotNullWithAutoIncrement = false + suppressDefaults = false -maxColumnNameLength = 30 Index: src/generator/src/templates/sql/base/oracle/columns.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/oracle/columns.vm,v retrieving revision 1.1 diff -u -r1.1 columns.vm --- src/generator/src/templates/sql/base/oracle/columns.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/oracle/columns.vm 19 Mar 2003 02:26:11 -0000 @@ -1,5 +1,6 @@ #foreach ($col in $table.Columns) #set ( $type = $dbprops.get($col.Type) ) + #if ($type == "DECIMAL") #set ( $type = "$type ($col.precision,$col.scale)")#end #set ( $size = $col.printSize() ) #set ( $default = $col.DefaultSetting ) #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"") ) Index: src/generator/src/templates/sql/base/oracle/db.props =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/oracle/db.props,v retrieving revision 1.2 diff -u -r1.2 db.props --- src/generator/src/templates/sql/base/oracle/db.props 23 Feb 2003 20:09:26 -0000 1.2 +++ src/generator/src/templates/sql/base/oracle/db.props 19 Mar 2003 02:26:11 -0000 @@ -12,9 +12,9 @@ BIGINT = NUMBER (20, 0) FLOAT = FLOAT REAL = NUMBER -DOUBLE = FLOAT +DOUBLE = DECIMAL NUMERIC = NUMBER -DECIMAL = NUMBER +DECIMAL = DECIMAL CHAR = CHAR VARCHAR = VARCHAR2 LONGVARCHAR = VARCHAR2 (2000) @@ -46,4 +46,4 @@ maxColumnNameLength = 30 -idMethod = sequence +idMethod=sequence Index: src/generator/src/templates/sql/base/oracle/index.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/oracle/index.vm,v retrieving revision 1.1 diff -u -r1.1 index.vm --- src/generator/src/templates/sql/base/oracle/index.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/oracle/index.vm 19 Mar 2003 02:26:11 -0000 @@ -1,3 +1,10 @@ +#if ($table.IndexTablespace == true) + #set($useIndexTablespace=true) +#else + #set($useIndexTablespace=false) +#end + + #foreach ($index in $table.Indices) -CREATE#if ($index.Unique)UNIQUE#end INDEX $index.Name ON $table.Name ($index.ColumnList); +CREATE#if ($index.Unique)UNIQUE#end INDEX $index.Name ON $table.Name ($index.ColumnList)#if ($useIndexTablespace) TABLESPACE $table.IndexTablespace#end; #end Index: src/generator/src/templates/sql/base/oracle/primarykey.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/oracle/primarykey.vm,v retrieving revision 1.1 diff -u -r1.1 primarykey.vm --- src/generator/src/templates/sql/base/oracle/primarykey.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/oracle/primarykey.vm 19 Mar 2003 02:26:11 -0000 @@ -3,5 +3,5 @@ #if ($table.hasPrimaryKey()) ALTER TABLE $table.Name ADD CONSTRAINT ${table.Name.substring(0,$length)}_PK -PRIMARY KEY ($table.printPrimaryKey()); +PRIMARY KEY ($table.printPrimaryKey()) #if ($table.IndexTablespace) USING INDEX TABLESPACE $table.IndexTablespace#else -- YAY!#end; #end Index: src/generator/src/templates/sql/base/oracle/unique.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/oracle/unique.vm,v retrieving revision 1.1 diff -u -r1.1 unique.vm --- src/generator/src/templates/sql/base/oracle/unique.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/oracle/unique.vm 19 Mar 2003 02:26:11 -0000 @@ -1,3 +1,10 @@ -#foreach ($unique in $table.Unices) - CONSTRAINT $unique.Name UNIQUE ($unique.ColumnList), +#if ($table.IndexTablespace == true) + #set($useIndexTablespace=true) +#else + #set($useIndexTablespace=false) #end + + +#foreach ($unique in $table.Unices) + CONSTRAINT $unique.Name UNIQUE ($unique.ColumnList)#if ($useIndexTablespace) USING INDEX TABLESPACE $table.IndexTablespace#end, +#end \ No newline at end of file Index: src/generator/src/templates/sql/base/postgresql/columns.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/postgresql/columns.vm,v retrieving revision 1.1 diff -u -r1.1 columns.vm --- src/generator/src/templates/sql/base/postgresql/columns.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/postgresql/columns.vm 19 Mar 2003 02:26:11 -0000 @@ -9,35 +9,35 @@ #else #set ( $size = "" ) #end - #if (($table.IdMethod == "native") && ($col.isPrimaryKey())) - #set ( $default = "DEFAULT nextval('$table.SequenceName')" ) - #else - #set ( $default = $col.DefaultSetting ) - #end + #set ( $default = $col.DefaultSetting ) #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"") ) #set ( $entry = "$col.Name $type $size $default $nullString" ) - #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT") ) + #if ($col.isAutoIncrement() && $table.IdMethod == "native") + #set ( $autoIncrement = $strings.select($col.isAutoIncrement(), $dbprops.get("AUTOINCREMENT"),"") ) + #else + #set ( $autoIncrement = " int" ) + #end #set ( $entry = $strings.select($col.isAutoIncrement(), "$col.Name $autoIncrement", $entry) ) ## ## the following works if you want to inline your foreign keys ## if you turn it on, be sure to comment out foreignkey.vm #if (false) - #if ($col.isForeignKey()) - #set ($fk = $col.ForeignKey) - #set ($entry = "$entry REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)") - #if ($fk.hasOnUpdate()) - #set ($entry = "$entry ON UPDATE $fk.OnUpdate ") - #end - #if ($fk.hasOnDelete()) - #set ($entry = "$entry ON DELETE $fk.OnDelete ") - #end - #end +#if ($col.isForeignKey()) +#set ($fk = $col.ForeignKey) +#set ($entry = "$entry REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)") +#if ($fk.hasOnUpdate()) +#set ($entry = "$entry ON UPDATE $fk.OnUpdate ") #end +#if ($fk.hasOnDelete()) +#set ($entry = "$entry ON DELETE $fk.OnDelete ") +#end +#end +#end +#set ( $entry = $strings.collapseSpaces("$entry,") ) + $strings.sub($entry," ,",",") ## add a nice comment #if ($col.isForeignKey()) - #set ($fk = $col.ForeignKey) +#set ($fk = $col.ForeignKey) -- REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames) #end -#set ( $entry = $strings.collapseSpaces("$entry,") ) - $strings.sub($entry," ,",",") #end Index: src/generator/src/templates/sql/base/postgresql/db.props =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/postgresql/db.props,v retrieving revision 1.1 diff -u -r1.1 db.props --- src/generator/src/templates/sql/base/postgresql/db.props 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/postgresql/db.props 19 Mar 2003 02:26:11 -0000 @@ -1,27 +1,23 @@ # Taken from java.sql.Types in the IBM 1.3 JDK # JDBC to PostgreSQL mappings. -# -# See http://www.postgresql.org/idocs/index.php?datatype.html for more -# information on PostgreSQL data types. -BIT = boolean +BIT = TINYINT = int2 SMALLINT = int2 INTEGER = integer BIGINT = int8 FLOAT = float REAL = float -BOOLEANCHAR = char +BOOLEANCHAR = boolean BOOLEANINT = int2 -DOUBLE = double -# numeric(precision, scale) / decimal(precision, scale) -NUMERIC = numeric -DECIMAL = decimal -CHAR = char +DOUBLE = double precision +NUMERIC = +DECIMAL = +CHAR = varchar VARCHAR = varchar LONGVARCHAR = bytea -DATE = date +DATE = date TIME = time TIMESTAMP = timestamp BINARY = bytea @@ -47,4 +43,3 @@ suppressDefaults = false idMethod=sequence - Index: src/generator/src/templates/sql/base/postgresql/index.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/postgresql/index.vm,v retrieving revision 1.1 diff -u -r1.1 index.vm --- src/generator/src/templates/sql/base/postgresql/index.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/postgresql/index.vm 19 Mar 2003 02:26:11 -0000 @@ -1,4 +1,3 @@ #foreach ($index in $table.Indices) CREATE#if($index.Unique) UNIQUE#end INDEX $index.Name ON $table.Name ($index.ColumnList); #end - Index: src/generator/src/templates/sql/base/postgresql/table.vm =================================================================== RCS file: /home/cvspublic/db-torque/src/generator/src/templates/sql/base/postgresql/table.vm,v retrieving revision 1.1 diff -u -r1.1 table.vm --- src/generator/src/templates/sql/base/postgresql/table.vm 10 Feb 2003 13:18:47 -0000 1.1 +++ src/generator/src/templates/sql/base/postgresql/table.vm 19 Mar 2003 02:26:12 -0000 @@ -18,4 +18,3 @@ ); #if($index.length() > 0)$strings.chop($index,1)#end - ------=_20030318203658_49646-- From brookschristopher@example.org Wed Mar 19 06:53:17 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 42920 invoked by uid 500); 19 Mar 2003 06:53:17 -0000 Received: (qmail 42917 invoked from network); 19 Mar 2003 06:53:17 -0000 Received: from icarus.apache.org (83.161.120.155) by daedalus.apache.org with SMTP; 19 Mar 2003 06:53:17 -0000 Received: (qmail 50541 invoked by uid 1280); 19 Mar 2003 06:53:16 -0000 Date: 19 Mar 2003 06:53:16 -0000 Message-ID: <brookschristopher@example.org> From: brookschristopher@example.org To: brookschristopher@example.org Subject: cvs commit: db-torque/src/test/org/apache/torque/util SqlExpressionTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mpoeschl 2003/03/18 22:53:16 Added: src/test/org/apache/torque/util SqlExpressionTest.java Log: some simple tests Revision Changes Path 1.1 db-torque/src/test/org/apache/torque/util/SqlExpressionTest.java Index: SqlExpressionTest.java =================================================================== package org.apache.torque.util; /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache Turbine" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact brookschristopher@example.org. * * 5. Products derived from this software may not be called "Apache", * "Apache Turbine", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ import junit.framework.TestCase; import org.apache.torque.adapter.DB; import org.apache.torque.adapter.DBFactory; /** * Tests for SqlExpression * * @author <a href="mailto:brookschristopher@example.org">Martin Poeschl</a> * @version $Id: SqlExpressionTest.java,v 1.1 2003/03/19 06:53:16 mpoeschl Exp $ */ public class SqlExpressionTest extends TestCase { private DB db = null; /** * Constructor for SqlExpressionTest. * @param arg0 */ public SqlExpressionTest(String arg0) { super(arg0); } /** * set up environment */ public void setUp() { try { db = DBFactory.create("mysql"); } catch (Exception ex) { ex.printStackTrace(); } } /** * Test for String buildInnerJoin(String, String) */ public void testBuildInnerJoinStringString() { String result = SqlExpression.buildInnerJoin("TA.COLA", "TB.COLB"); assertEquals(result, "TA.COLA=TB.COLB"); } /** * Test for String buildInnerJoin(String, String, boolean, DB) */ public void testBuildInnerJoinStringStringbooleanDB() { String result = SqlExpression.buildInnerJoin("TA.COLA", "TB.COLB", true, db); assertEquals(result, "TA.COLA=TB.COLB"); } /** * Test for String buildIn(String, Object, SqlEnum, boolean, DB) */ public void testBuildInStringObjectSqlEnumbooleanDB() { String[] values = new String[] { "42", "43", "44" }; String result = SqlExpression.buildIn("COL", values, SqlEnum.IN, true, db); assertEquals(result, "COL IN ('42','43','44')"); } } From brookschristopher@example.org Wed Mar 19 16:06:02 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 2773 invoked from network); 19 Mar 2003 16:06:02 -0000 Received: from www3.kc.aoindustries.com (83.161.120.155) by daedalus.apache.org with SMTP; 19 Mar 2003 16:06:02 -0000 Received: from ericemminger.com (163-44.9-67.se.rr.com [83.161.120.155] (may be forged)) (authenticated) by www3.kc.aoindustries.com (8.11.6/8.11.6) with ESMTP id h2JG62B09227; Wed, 19 Mar 2003 10:06:02 -0600 Message-ID: <brookschristopher@example.org> Date: Wed, 19 Mar 2003 11:05:53 -0500 From: Eric Emminger <brookschristopher@example.org> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Turbine Torque Developers List <brookschristopher@example.org> CC: brookschristopher@example.org Subject: Re: Precision, scale, and index tablespaces. References: <brookschristopher@example.org> In-Reply-To: <brookschristopher@example.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Chris! > we've been using Torque for a while to generate SQL based on our OJB > repository. We've had to tweak a few things to get them to work though, > and we thought we should contribute them back. These sound like great updates. Would you like to comment on using OJB with Torque? I'd be very interested in your perspective. I've been using Torque for a while, and OJB appears to have some interesting advantages, so I'm wondering about switching. Or, using both together may be even better. What do you think? > Attached is a patch that addresses all these issues. Here's a short list > of the affected files: > If you have any questions, I'd be glad to answer them. We're eager to get > the changes into Torque so that we don't have to maintain a separate local > version. Could you add this into Scarab? I believe that will make it easier for a developer to review and commit the changes. Eric From brookschristopher@example.org Thu Mar 20 20:34:43 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 79894 invoked by uid 500); 20 Mar 2003 20:34:43 -0000 Received: (qmail 79891 invoked from network); 20 Mar 2003 20:34:43 -0000 Received: from icarus.apache.org (83.161.120.155) by daedalus.apache.org with SMTP; 20 Mar 2003 20:34:43 -0000 Received: (qmail 36097 invoked by uid 1280); 20 Mar 2003 20:34:42 -0000 Date: 20 Mar 2003 20:34:42 -0000 Message-ID: <brookschristopher@example.org> From: brookschristopher@example.org To: brookschristopher@example.org Subject: cvs commit: db-torque/src/java/org/apache/torque/util SqlExpression.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mpoeschl 2003/03/20 12:34:42 Modified: src/java/org/apache/torque/util SqlExpression.java Log: replace StringStack with HashSet Revision Changes Path 1.22 +10 -6 db-torque/src/java/org/apache/torque/util/SqlExpression.java Index: SqlExpression.java =================================================================== RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/SqlExpression.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- SqlExpression.java 18 Jan 2003 16:39:51 -0000 1.21 +++ SqlExpression.java 20 Mar 2003 20:34:42 -0000 1.22 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,14 +56,17 @@ import java.lang.reflect.Array; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.apache.torque.TorqueException; import org.apache.torque.adapter.DB; import org.apache.torque.om.DateKey; import org.apache.torque.om.ObjectKey; import org.apache.torque.om.StringKey; -import org.apache.torque.TorqueException; -import org.apache.commons.collections.StringStack; + /** * This class represents a part of an SQL query found in the <code>WHERE</code> @@ -78,6 +81,7 @@ * @author <a href="mailto:brookschristopher@example.org">John D. McNally</a> * @author <a href="mailto:brookschristopher@example.org">Daniel Rall</a> * @author <a href="mailto:brookschristopher@example.org">Fedor Karpelevitch</a> + * @author <a href="mailto:brookschristopher@example.org">Martin Poeschl</a> * @version $Id$ */ public class SqlExpression @@ -506,7 +510,7 @@ } whereClause.append(comparison); - StringStack inClause = new StringStack(); + HashSet inClause = new HashSet(); if (criteria instanceof List) { Iterator iter = ((List) criteria).iterator(); @@ -532,7 +536,7 @@ } } whereClause.append('(') - .append(inClause.toString(",")) + .append(StringUtils.join(inClause.iterator(), ",")) .append(')'); } From brookschristopher@example.org Fri Mar 21 08:36:25 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 60053 invoked by uid 500); 21 Mar 2003 08:36:25 -0000 Received: (qmail 60048 invoked from network); 21 Mar 2003 08:36:25 -0000 Received: from icarus.apache.org (83.161.120.155) by daedalus.apache.org with SMTP; 21 Mar 2003 08:36:25 -0000 Received: (qmail 92706 invoked by uid 1280); 21 Mar 2003 08:36:24 -0000 Date: 21 Mar 2003 08:36:24 -0000 Message-ID: <brookschristopher@example.org> From: brookschristopher@example.org To: brookschristopher@example.org Subject: cvs commit: db-torque/src/java/org/apache/torque/util BasePeer.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mpoeschl 2003/03/21 00:36:23 Modified: src/java/org/apache/torque/util BasePeer.java Log: replace StringStack Revision Changes Path 1.61 +25 -28 db-torque/src/java/org/apache/torque/util/BasePeer.java Index: BasePeer.java =================================================================== RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/BasePeer.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- BasePeer.java 10 Jan 2003 15:33:24 -0000 1.60 +++ BasePeer.java 21 Mar 2003 08:36:23 -0000 1.61 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,11 +66,13 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import org.apache.commons.collections.StringStack; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.torque.Torque; import org.apache.torque.TorqueException; @@ -105,6 +107,7 @@ * @author <a href="mailto:brookschristopher@example.org">John D. McNally</a> * @author <a href="mailto:brookschristopher@example.org">Brett McLaughlin</a> * @author <a href="mailto:brookschristopher@example.org">Stephen Haberman</a> + * @author <a href="mailto:brookschristopher@example.org">Martin Poeschl</a> * @version $Id$ */ public abstract class BasePeer implements java.io.Serializable @@ -435,8 +438,7 @@ } /** - * Method to perform deletes based on values and keys in a - * Criteria. + * Method to perform deletes based on values and keys in a Criteria. * * @param criteria The criteria to use. * @param con A Connection. @@ -452,7 +454,7 @@ // Set up a list of required tables and add extra entries to // criteria if directed to delete all related records. // StringStack.add() only adds element if it is unique. - StringStack tables = new StringStack(); + HashSet tables = new HashSet(); Iterator it = criteria.keySet().iterator(); while (it.hasNext()) { @@ -503,13 +505,14 @@ } } } - - for (int i = 0; i < tables.size(); i++) + Iterator tabIt = tables.iterator(); + while (tabIt.hasNext()) { + String tab = (String) tabIt.next(); KeyDef kd = new KeyDef(); - StringStack whereClause = new StringStack(); + HashSet whereClause = new HashSet(); - ColumnMap[] columnMaps = dbMap.getTable(tables.get(i)).getColumns(); + ColumnMap[] columnMaps = dbMap.getTable(tab).getColumns(); for (int j = 0; j < columnMaps.length; j++) { ColumnMap colMap = columnMaps[j]; @@ -545,8 +548,8 @@ TableDataSet tds = null; try { - tds = new TableDataSet(con, tables.get(i), kd); - String sqlSnippet = whereClause.toString(" AND "); + tds = new TableDataSet(con, tab, kd); + String sqlSnippet = StringUtils.join(whereClause.iterator(), " AND "); category.debug("BasePeer.doDelete: whereClause=" + sqlSnippet); @@ -1134,7 +1137,6 @@ criterion.setDB(db); whereClause.add(criterion.toString()); - } List join = criteria.getJoinL(); @@ -1843,8 +1845,7 @@ Connection db = null; try { - db = - Transaction.beginOptional( + db = Transaction.beginOptional( selectCriteria.getDbName(), updateValues.isUseTransaction()); doUpdate(selectCriteria, updateValues, db); @@ -1885,21 +1886,22 @@ // Set up a list of required tables. StringStack.add() // only adds element if it is unique. - StringStack tables = new StringStack(); + HashSet tables = new HashSet(); Iterator it = selectCriteria.keySet().iterator(); while (it.hasNext()) { tables.add(selectCriteria.getTableName((String) it.next())); } - for (int i = 0; i < tables.size(); i++) + Iterator tabIt = tables.iterator(); + while (tabIt.hasNext()) { + String tab = (String) tabIt.next(); KeyDef kd = new KeyDef(); - StringStack whereClause = new StringStack(); + HashSet whereClause = new HashSet(); DatabaseMap tempDbMap = dbMap; - ColumnMap[] columnMaps = - tempDbMap.getTable(tables.get(i)).getColumns(); + ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns(); for (int j = 0; j < columnMaps.length; j++) { ColumnMap colMap = columnMaps[j]; @@ -1907,8 +1909,7 @@ { kd.addAttrib(colMap.getColumnName()); } - String key = - new StringBuffer(colMap.getTableName()) + String key = new StringBuffer(colMap.getTableName()) .append('.') .append(colMap.getColumnName()) .toString(); @@ -1936,8 +1937,8 @@ try { // Get affected records. - tds = new TableDataSet(con, tables.get(i), kd); - String sqlSnippet = whereClause.toString(" AND "); + tds = new TableDataSet(con, tab, kd); + String sqlSnippet = StringUtils.join(whereClause.iterator(), " AND "); category.debug("BasePeer.doUpdate: whereClause=" + sqlSnippet); tds.where(sqlSnippet); tds.fetchRecords(); @@ -1949,10 +1950,7 @@ for (int j = 0; j < tds.size(); j++) { Record rec = tds.getRecord(j); - BasePeer.insertOrUpdateRecord( - rec, - tables.get(i), - updateValues); + BasePeer.insertOrUpdateRecord(rec, tab, updateValues); } } catch (Exception e) @@ -2406,7 +2404,6 @@ StringBuffer sb = new StringBuffer(); criterion.appendPsTo(sb, params); whereClause.add(sb.toString()); - } List join = criteria.getJoinL(); From brookschristopher@example.org Fri Mar 21 15:05:01 2003 Return-Path: <brookschristopher@example.org> Mailing-List: contact brookschristopher@example.org; run by ezmlm Delivered-To: mailing list brookschristopher@example.org Received: (qmail 50535 invoked by uid 500); 21 Mar 2003 15:05:01 -0000 Received: (qmail 50530 invoked from network); 21 Mar 2003 15:05:01 -0000 Received: from icarus.apache.org (83.161.120.155) by daedalus.apache.org with SMTP; 21 Mar 2003 15:05:01 -0000 Received: (qmail 87530 invoked by uid 1280); 21 Mar 2003 15:05:01 -0000 Date: 21 Mar 2003 15:05:01 -0000 Message-ID: <brookschristopher@example.org> From: brookschristopher@example.org To: brookschristopher@example.org Subject: cvs commit: db-torque/src/rttest extext-schema.xml ext-schema.xml test-schema.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mpoeschl 2003/03/21 07:05:01 Modified: src/generator/src/test/org/apache/torque/engine/database package-schema.xml package2-schema.xml src/rttest extext-schema.xml ext-schema.xml test-schema.xml Log: use 3_1.dtd Revision Changes Path 1.2 +10 -10 db-torque/src/generator/src/test/org/apache/torque/engine/database/package-schema.xml Index: package-schema.xml =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/package-schema.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- package-schema.xml 10 Feb 2003 13:21:35 -0000 1.1 +++ package-schema.xml 21 Mar 2003 15:05:01 -0000 1.2 @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> -<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd"> - -<database name="packagedb" defaultIdMethod="idbroker"> - <table name="table_a"> - <column name="table_a_id" required="true" primaryKey="true" type="INTEGER" /> - <column name="col_a" type="CHAR" size="5" /> - </table> -</database> - +<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> +<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database_3_1.dtd"> + +<database name="packagedb" defaultIdMethod="idbroker"> + <table name="table_a"> + <column name="table_a_id" required="true" primaryKey="true" type="INTEGER" /> + <column name="col_a" type="CHAR" size="5" /> + </table> +</database> + 1.2 +11 -11 db-torque/src/generator/src/test/org/apache/torque/engine/database/package2-schema.xml Index: package2-schema.xml =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/package2-schema.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- package2-schema.xml 10 Feb 2003 13:21:35 -0000 1.1 +++ package2-schema.xml 21 Mar 2003 15:05:01 -0000 1.2 @@ -1,11 +1,11 @@ -<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> -<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd"> - -<database name="packagedb2" defaultIdMethod="idbroker" package="packagefromdb"> - - <table name="table_a"> - <column name="table_a_id" required="true" primaryKey="true" type="INTEGER" /> - <column name="col_a" type="CHAR" size="5" /> - </table> -</database> - +<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> +<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database_3_1.dtd"> + +<database name="packagedb2" defaultIdMethod="idbroker" package="packagefromdb"> + + <table name="table_a"> + <column name="table_a_id" required="true" primaryKey="true" type="INTEGER" /> + <column name="col_a" type="CHAR" size="5" /> + </table> +</database> + 1.2 +1 -1 db-torque/src/rttest/extext-schema.xml Index: extext-schema.xml =================================================================== RCS file: /home/cvs/db-torque/src/rttest/extext-schema.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- extext-schema.xml 20 Dec 2002 16:39:21 -0000 1.1 +++ extext-schema.xml 21 Mar 2003 15:05:01 -0000 1.2 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> -<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd"> +<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database_3_1.dtd"> <database name="@DATABASE_DEFAULT@" 1.2 +1 -1 db-torque/src/rttest/ext-schema.xml Index: ext-schema.xml =================================================================== RCS file: /home/cvs/db-torque/src/rttest/ext-schema.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ext-schema.xml 20 Dec 2002 16:39:21 -0000 1.1 +++ ext-schema.xml 21 Mar 2003 15:05:01 -0000 1.2 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> -<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd"> +<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database_3_1.dtd"> <database name="@DATABASE_DEFAULT@" 1.10 +86 -86 db-torque/src/rttest/test-schema.xml Index: test-schema.xml =================================================================== RCS file: /home/cvs/db-torque/src/rttest/test-schema.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- test-schema.xml 18 Jan 2003 14:51:34 -0000 1.9 +++ test-schema.xml 21 Mar 2003 15:05:01 -0000 1.10 @@ -1,86 +1,86 @@ -<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> -<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd"> -<!-- this schema is used to test problems users reported --> - -<database name="@DATABASE_DEFAULT@" defaultIdMethod="idbroker" package="org.apache.torque.test"> - - <external-schema filename="ext-schema.xml" /> - - <!-- TRQS15 --> - <table name="varchar_pk"> - <column name="test_key" required="true" primaryKey="true" type="VARCHAR" size="30" /> - </table> - - <!-- TRQS17 --> - <table name="timestamp_pk"> - <column name="test_key" required="true" primaryKey="true" type="TIMESTAMP" /> - <column name="col_a" type="TIMESTAMP" /> - <!-- TRQS28 --> - <column name="col_b" type="BOOLEANINT" javaType="object" /> - <column name="col_c" type="BOOLEANCHAR" javaType="object" /> - <!-- TRQ2 --> - <column name="remote" type="CHAR" size="10"/> - </table> - - <!-- TRQ12 with multiple pks, combo key parse fails --> - <table name="multi_pk" idMethod="none"> - <column name="pk1" required="true" primaryKey="true" type="VARCHAR" size="30" /> - <column name="pk2" required="true" primaryKey="true" type="INTEGER" /> - <column name="pk3" required="true" primaryKey="true" type="CHAR" size="5" /> - <column name="col_a" type="BOOLEANINT" /> - <column name="col_b" type="BOOLEANINT" javaType="object" /> - </table> - - <!-- TRQS77 --> - <table name="course"> - <column name="id" required="true" primaryKey="true" type="INTEGER" /> - <column name="col_a" type="CHAR" size="5" /> - </table> - - <table name="course_number" description="Number for a course"> - <column name="course_id" required="true" type="INTEGER"/> - <column name="course_num" required="true" type="INTEGER"/> - - <foreign-key foreignTable="course" - onDelete="cascade" onUpdate="cascade"> - <reference local="course_id" foreign="id"/> - </foreign-key> - </table> - - <table name="course_number1" description="Number for a course"> - <column name="course_num" required="true" type="INTEGER"/> - <column name="course_id" required="true" type="INTEGER"/> - - <foreign-key foreignTable="course" - onDelete="cascade" onUpdate="cascade"> - <reference local="course_id" foreign="id"/> - </foreign-key> - </table> - - <!-- reference to external schema --> - <table name="ext_schema"> - <column name="ext_schema_id" required="true" primaryKey="true" type="INTEGER"/> - <column name="ext_id" type="INTEGER"/> - <column name="test" required="true" type="INTEGER"/> - - <foreign-key foreignTable="ext"> - <reference local="ext_id" foreign="ext_id"/> - </foreign-key> - </table> - - <table name="extext_schema"> - <column name="extext_schema_id" required="true" primaryKey="true" type="INTEGER"/> - <column name="extext_id" type="INTEGER"/> - <column name="test" required="true" type="INTEGER"/> - - <foreign-key foreignTable="extext"> - <reference local="extext_id" foreign="extext_id"/> - </foreign-key> - </table> - - <!-- TRQS118 primary key of type FLOAT --> - <table name="float_pk"> - <column name="test_key" required="true" primaryKey="true" type="FLOAT" /> - </table> - -</database> +<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> +<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database_3_1.dtd"> +<!-- this schema is used to test problems users reported --> + +<database name="@DATABASE_DEFAULT@" defaultIdMethod="idbroker" package="org.apache.torque.test"> + + <external-schema filename="ext-schema.xml" /> + + <!-- TRQS15 --> + <table name="varchar_pk"> + <column name="test_key" required="true" primaryKey="true" type="VARCHAR" size="30" /> + </table> + + <!-- TRQS17 --> + <table name="timestamp_pk"> + <column name="test_key" required="true" primaryKey="true" type="TIMESTAMP" /> + <column name="col_a" type="TIMESTAMP" /> + <!-- TRQS28 --> + <column name="col_b" type="BOOLEANINT" javaType="object" /> + <column name="col_c" type="BOOLEANCHAR" javaType="object" /> + <!-- TRQ2 --> + <column name="remote" type="CHAR" size="10"/>
{'source': 'Apache Software Foundation Public Mail Archives'}