Author: tfischer
Date: Wed Sep  3 19:49:01 2014
New Revision: 1622336

URL: http://svn.apache.org/r1622336
Log:
TORQUE-312 fix NPE in generation process

Modified:
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java?rev=1622336&r1=1622335&r2=1622336&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
 Wed Sep  3 19:49:01 2014
@@ -748,11 +748,15 @@ public class OMForeignKeyTransformer
      * and adds the local column as a child of it.
      *
      * @param localTable the local table element.
-     * @param reference the refenced element to enrich.
+     * @param reference the referenced element to enrich.
+     *
+     * @throws SourceTransformerException if the referenced column
+     *         cannot be found.
      */
     protected void createLocalElementForReference(
             final SourceElement localTable,
             final SourceElement reference)
+        throws SourceTransformerException
     {
         {
             String localColumnName = (String)
@@ -763,6 +767,15 @@ public class OMForeignKeyTransformer
                             ReferenceChildElementName.LOCAL_COLUMN);
             SourceElement column
                     = FindHelper.findColumn(localTable, localColumnName);
+            if (column == null)
+            {
+                Object localTableName = localTable.getAttribute(
+                        TorqueSchemaAttributeName.NAME);
+                throw new SourceTransformerException(
+                        "Error defining foreign key in table " + localTableName
+                           + " : Could not find local column " + 
localColumnName
+                           + " in table " + localTableName);
+            }
             localColumnElement.getChildren().add(column);
             reference.getChildren().add(localColumnElement);
         }



---------------------------------------------------------------------
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