openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r1292578 - in /openjpa/branches/2.2.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
Date Wed, 22 Feb 2012 23:14:57 GMT
Author: kwsutter
Date: Wed Feb 22 23:14:57 2012
New Revision: 1292578

URL: http://svn.apache.org/viewvc?rev=1292578&view=rev
Log:
OPENJPA-2123.  Introduce a new DBDictionary property (trimStringColumns) that allows for trimming
of String columns when retrieved from the ResultSet.

Modified:
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1292578&r1=1292577&r2=1292578&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Feb 22 23:14:57 2012
@@ -44,7 +44,6 @@ import java.sql.Statement;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.sql.Types;
-import java.text.DateFormatSymbols;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -61,8 +60,6 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.TimeZone;
-import java.util.spi.TimeZoneNameProvider;
 
 import javax.sql.DataSource;
 
@@ -288,6 +285,7 @@ public class DBDictionary
     public boolean storageLimitationsFatal = false;
     public boolean storeLargeNumbersAsStrings = false;
     public boolean storeCharsAsNumbers = true;
+    public boolean trimStringColumns = false;
     public boolean useGetBytesForBlobs = false;
     public boolean useSetBytesForBlobs = false;
     public boolean useGetObjectForBlobs = false;
@@ -883,7 +881,11 @@ public class DBDictionary
      */
     public String getString(ResultSet rs, int column)
         throws SQLException {
-        return rs.getString(column);
+        String res = rs.getString(column);
+        if ((res != null) && trimStringColumns) {
+            res = res.trim();
+        }
+        return res;
     }
 
     /**

Modified: openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml?rev=1292578&r1=1292577&r2=1292578&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml (original)
+++ openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml Wed Feb 22
23:14:57 2012
@@ -3325,6 +3325,21 @@ and the token <literal>{0}</literal> to 
 Defaults to <literal>"TRIM(LEADING {1} FROM {0})"</literal>.
                     </para>
                 </listitem>
+                <listitem id="DBDictionary.TrimStringColumns">
+                    <para>
+                    <indexterm>
+                        <primary>
+                            String
+                        </primary>
+                        <secondary>
+                            TrimStringColumns
+                        </secondary>
+                    </indexterm>
+<literal>TrimStringColumns</literal>: When <literal>true</literal>,
the resulting String from
+<methodname>ResultSet.getString</methodname> will be trimmed of trailing white
space.  Defaults
+to <literal>false</literal>.
+                    </para>
+                </listitem>
                 <listitem id="DBDictionary.TrimTrailingFunction">
                     <para>
                     <indexterm>



Mime
View raw message