Author: tfischer
Date: Tue Jul 12 12:57:59 2011
New Revision: 1145573

URL: http://svn.apache.org/viewvc?rev=1145573&view=rev
Log:
- make findbugs happy on generated code
- check whether Torque is initialized before calling Torque.getDefaultDb() in 
order to not run into a NullPointerException during the comparison of the 
Default DB and the criteria's DB

Modified:
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setDbName.vm

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setDbName.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setDbName.vm?rev=1145573&r1=1145572&r2=1145573&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setDbName.vm
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setDbName.vm
 Tue Jul 12 12:57:59 2011
@@ -22,12 +22,13 @@
 ## Creates the setDbName method for the base peer.
 ## This template expects no input.
 ##
-    private static void setDbName(Criteria crit)
+    private static void setDbName(Criteria crit) throws TorqueException
     {
-        // Set the correct dbName if it has not been overridden
-        // crit.getDbName will return the same object if not set to
-        // another value so == check is okay and faster
-        if (crit.getDbName() == Torque.getDefaultDB())
+        if (!Torque.isInit())
+        {
+            throw new TorqueException("Torque is not initialized");
+        }
+        if (Torque.getDefaultDB().equals(crit.getDbName()))
         {
             crit.setDbName(${peerClassName}.DATABASE_NAME);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to