You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2009/09/24 03:06:51 UTC

svn commit: r818337 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java

Author: jrbauer
Date: Thu Sep 24 01:06:50 2009
New Revision: 818337

URL: http://svn.apache.org/viewvc?rev=818337&view=rev
Log:
Update TestEJBQLFunction test to assert empty strings as null for the Oracle DB.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java?rev=818337&r1=818336&r2=818337&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java Thu Sep 24 01:06:50 2009
@@ -21,6 +21,9 @@
 import java.util.List;
 import javax.persistence.EntityManager;
 
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.OracleDictionary;
 import org.apache.openjpa.persistence.common.apps.Address;
 import org.apache.openjpa.persistence.common.apps.CompUser;
 import org.apache.openjpa.persistence.common.apps.FemaleUser;
@@ -129,7 +132,21 @@
         user = em.find(CompUser.class, userid1);
         em.refresh(user);
         assertNotNull(user);
-        assertEquals("", user.getName());
+        // Empty strings are stored as null on Oracle so the assertion below
+        // must be handled differently on that DB.  The docs indicate that
+        // this may not be the case in future releases so either result is
+        // allowed.
+        // The note in this section of Oracle doc explains the behavior:
+        // http://download.oracle.com/docs/cd/B14117_01/server.101/ +
+        // b10759/sql_elements005.htm#sthref511
+        DBDictionary dict = ((JDBCConfiguration) getEmf().getConfiguration())
+            .getDBDictionaryInstance();
+        if (dict instanceof OracleDictionary) {
+            assertTrue(user.getName() == null ||
+                "".equals(user.getName()));
+        } else {
+            assertEquals("", user.getName());            
+        }
 
         endTx(em);
         endEm(em);
@@ -407,4 +424,5 @@
         }
         return user;
     }
+    
 }