Author: tfischer
Date: Fri Feb  1 01:14:14 2013
New Revision: 1441287

URL: http://svn.apache.org/viewvc?rev=1441287&view=rev
Log:
TORQUE-251 fix SQL errors in the test project
TORQUE-263 Allow not generating drop... commands in sql

Added:
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/dropSkipDecider.vm
Modified:
    
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/customizing-generation.xml
    
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/running-the-generator.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
    db/torque/torque4/trunk/torque-test/pom.xml

Modified: 
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/customizing-generation.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/customizing-generation.xml?rev=1441287&r1=1441286&r2=1441287&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/customizing-generation.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/customizing-generation.xml
 Fri Feb  1 01:14:14 2013
@@ -317,6 +317,22 @@
     </tr>
 
     <tr>
+      <td colspan="3"><strong> SQL Template Variables </strong>
+      (only used for the generation of sql ddl)</td>
+    </tr>
+    <tr>
+      <td><code>torque.sql.generate.drops</code></td>
+      <td><code>true</code></td>
+      <td>
+        If set to true (default), Torque will generate drop commands
+        in the sql which drop and re-create all known tables.
+        If set to false, Torque will not generate any drop commands - 
+        Then you need to male sure to execute the sql file(s)
+        against an empty schema.
+      </td>
+    </tr>
+
+    <tr>
       <td colspan="3"><strong> JDBC2Schema settings </strong>
         (not used for other generation targets)</td>
     </tr>

Modified: 
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/running-the-generator.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/running-the-generator.xml?rev=1441287&r1=1441286&r2=1441287&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/running-the-generator.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/orm-reference/running-the-generator.xml
 Fri Feb  1 01:14:14 2013
@@ -164,6 +164,11 @@
         directory ending on -schema.xml; the output goes to the directory 
         target/generated-sql.
       </p>
+      <p>
+        See the <a href="customizing-generation.html">Customizing</a> page for 
a
+        documentation of available options which can be used to customize
+        the generated output.
+      </p>
     </subsection> 
     <subsection name="Generation of html documentation">
       <p>

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties?rev=1441287&r1=1441286&r2=1441287&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
 Fri Feb  1 01:14:14 2013
@@ -14,3 +14,4 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+torque.sql.generate.drops = true

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml?rev=1441287&r1=1441286&r2=1441287&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
 Fri Feb  1 01:14:14 2013
@@ -29,18 +29,8 @@
           outlet="torque.sql.ddl.databaseStart"/>
     </mergepoint>
     <mergepoint name="drop">
-      <action xsi:type="traverseAllAction" 
-          element="all-views/view" 
-          outlet="torque.sql.ddl.dropView"/>
-      <action xsi:type="traverseAllAction" 
-          element="all-tables/table" 
-          outlet="torque.sql.ddl.dropForeignKeySkipDecider"/>
-      <action xsi:type="traverseAllAction" 
-          element="all-tables/table" 
-          outlet="torque.sql.ddl.dropTableSkipDecider"/>
-      <action xsi:type="traverseAllAction" 
-          element="databaseSchema" 
-          outlet="torque.sql.ddl.dropDatabaseSchema"/>
+      <action xsi:type="applyAction" 
+          outlet="torque.sql.ddl.dropSkipDecider"/>
     </mergepoint>
     <mergepoint name="createSchema">
       <action xsi:type="traverseAllAction" 
@@ -70,6 +60,25 @@
     <mergepoint name="databaseEnd" />
   </outlet>
 
+  <outlet name="torque.sql.ddl.dropSkipDecider"
+      xsi:type="velocityOutlet"
+      path="ddl/dropSkipDecider.vm">
+    <mergepoint name="drop">
+      <action xsi:type="traverseAllAction" 
+          element="all-views/view" 
+          outlet="torque.sql.ddl.dropView"/>
+      <action xsi:type="traverseAllAction" 
+          element="all-tables/table" 
+          outlet="torque.sql.ddl.dropForeignKeySkipDecider"/>
+      <action xsi:type="traverseAllAction" 
+          element="all-tables/table" 
+          outlet="torque.sql.ddl.dropTableSkipDecider"/>
+      <action xsi:type="traverseAllAction" 
+          element="databaseSchema" 
+          outlet="torque.sql.ddl.dropDatabaseSchema"/>
+    </mergepoint>
+  </outlet>
+
   <outlet name="torque.sql.ddl.dropForeignKeySkipDecider"
       xsi:type="velocityOutlet"
       path="ddl/tableSkipDecider.vm">

Added: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/dropSkipDecider.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/dropSkipDecider.vm?rev=1441287&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/dropSkipDecider.vm
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/dropSkipDecider.vm
 Fri Feb  1 01:14:14 2013
@@ -0,0 +1,19 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+#if ($torqueGen.booleanOption("torque.sql.generate.drops"))##
+$torqueGen.mergepoint("drop")##
+#end
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-test/pom.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/pom.xml?rev=1441287&r1=1441286&r2=1441287&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/pom.xml (original)
+++ db/torque/torque4/trunk/torque-test/pom.xml Fri Feb  1 01:14:14 2013
@@ -89,18 +89,19 @@
     <plugins>
       <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.7</version>
         <executions>
           <execution>
             <id>clean-generated-sources</id>
             <phase>clean</phase>
             <configuration>
-              <tasks>
+              <target>
                 <!--  remove old generated sources -->
                 <echo message="Deleting directory src/main/generated-java" />
                 <delete dir="src/main/generated-java" />
                 <echo message="Deleting directory target/torque" />
                 <delete dir="target/torque" />
-              </tasks>
+              </target>
             </configuration>
             <goals>
               <goal>run</goal>
@@ -110,7 +111,7 @@
             <id>filter-schema</id>
             <phase>generate-sources</phase>
             <configuration>
-              <tasks>                
+              <target>
                 <!-- schema files need to be copied to insert idMethod -->
                 <copy todir="target/torque/test/schema">
                   <fileset dir="src/main/schema" />
@@ -132,12 +133,53 @@
                 <copy todir="target/torque/test/sql">
                   <fileset dir="src/test/sql" />
                 </copy>
-              </tasks>
+              </target>
             </configuration>
             <goals>
               <goal>run</goal>
             </goals>
           </execution>
+          <execution>
+            <id>test-database-filled</id>
+            <phase>generate-sources</phase>
+            <configuration>
+              <target>
+                <sql driver="${torque.driver}" 
+                   url="${torque.database.url}" 
+                   userid="${torque.database.user}"
+                   password="${torque.database.password}"
+                   errorproperty="cannot.access.book.table">
+                  select count(*) from book;
+                </sql>
+                <property name="executeDrop" value="true"/>
+              </target>
+              <exportAntProperties>true</exportAntProperties>
+              <failOnError>false</failOnError>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>shutdown-db-after-test-database</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+           <configuration>
+              <target>
+                <sql driver="${torque.driver}" 
+                   url="${torque.database.shutdown.url}" 
+                   userid="${torque.database.user}"
+                   password="${torque.database.password}">
+                  -- do nothing
+                </sql>
+              </target>
+              <exportAntProperties>true</exportAntProperties>
+              <failOnError>false</failOnError>
+              <skip>${torque.database.shutdown.skip}</skip>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
 
@@ -188,6 +230,7 @@
               </sourceExcludes>
               <options>
                 <torque.database>${torque.targetDatabase}</torque.database>
+                
<torque.sql.generate.drops>${executeDrop}</torque.sql.generate.drops>
               </options>
             </configuration>
           </execution>
@@ -330,7 +373,7 @@
               <url>${torque.database.url}</url>
               <username>${torque.database.user}</username>
               <password>${torque.database.password}</password>
-              <onError>continue</onError>
+              <onError>abort</onError>
               <autocommit>true</autocommit>
               <orderFile>ascending</orderFile>
               <fileset>
@@ -359,7 +402,7 @@
               <url>${torque.database.url}</url>
               <username>${torque.database.user}</username>
               <password>${torque.database.password}</password>
-              <onError>continue</onError>
+              <onError>abort</onError>
               <autocommit>true</autocommit>
               <orderFile>ascending</orderFile>
               <fileset>
@@ -525,6 +568,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>derby</artifactId>
+                <groupId>org.apache.derby</groupId>
+                <version>10.8.2.2</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -579,6 +632,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>hsqldb</artifactId>
+                <groupId>org.hsqldb</groupId>
+                <version>2.2.8</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -634,6 +697,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>hsqldb</artifactId>
+                <groupId>org.hsqldb</groupId>
+                <version>2.2.8</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -684,6 +757,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>derbyclient</artifactId>
+                <groupId>org.apache.derby</groupId>
+                <version>10.8.2.2</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -734,6 +817,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>mysql-connector-java</artifactId>
+                <groupId>mysql</groupId>
+                <version>5.0.4</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -784,6 +877,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>jtds</artifactId>
+                <groupId>net.sourceforge.jtds</groupId>
+                <version>1.2.7</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -834,6 +937,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>ojdbc14</artifactId>
+                <groupId>com.oracle</groupId>
+                <version>10.2.0.3.0</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -884,6 +997,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>postgresql</artifactId>
+                <groupId>postgresql</groupId>
+                <version>9.1-901.jdbc4</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>
@@ -934,6 +1057,16 @@
               </dependency>
             </dependencies>
           </plugin>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <artifactId>mysql-connector-java</artifactId>
+                <groupId>mysql</groupId>
+                <version>3.1.12</version>
+              </dependency>
+            </dependencies>
+          </plugin>
         </plugins>
       </build>
     </profile>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org

Reply via email to