openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r706493 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: kernel/JDBCStoreManager.java sql/DBDictionary.java sql/SybaseDictionary.java
Date Tue, 21 Oct 2008 02:03:27 GMT
Author: faywang
Date: Mon Oct 20 19:03:26 2008
New Revision: 706493

URL: http://svn.apache.org/viewvc?rev=706493&view=rev
Log:
OPENJPA-745 raise string right truncation error for Sybase

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java?rev=706493&r1=706492&r2=706493&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
Mon Oct 20 19:03:26 2008
@@ -920,6 +920,7 @@
                 _conn = connectInternal();
             if (ref)
                 _conn.ref();
+            _dict.initializeSettings(_conn);
         } catch (SQLException se) {
             throw SQLExceptions.getStore(se, _dict);
         } finally {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=706493&r1=706492&r2=706493&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Mon Oct 20 19:03:26 2008
@@ -200,6 +200,7 @@
     public String selectWords = null;
     public String fixedSizeTypeNames = null;
     public String schemaCase = SCHEMA_CASE_UPPER;
+    public boolean setStringRightTruncationOn = true;
 
     // sql
     public String validationSQL = null;
@@ -4561,4 +4562,8 @@
     				length));
     	return name;
     }
+    
+    public void initializeSettings(Connection conn) 
+        throws SQLException {
+    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java?rev=706493&r1=706492&r2=706493&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
Mon Oct 20 19:03:26 2008
@@ -268,6 +268,20 @@
         throws SQLException {
         return new SybaseConnection(super.decorate(conn));
     }
+    
+    public void initializeSettings(Connection conn)
+        throws SQLException {
+        // In order for Sybase to raise the truncation exception when the 
+        // string length is greater than the column length for Char, VarChar, 
+        // Binary, VarBinary, the "set string_rtruncation on" must be executed. 
+        // This setting is effective for the duration of current connection.
+        if (setStringRightTruncationOn) {
+            String str = "set string_rtruncation on";
+            PreparedStatement stmnt = prepareStatement(conn, str);        
+            stmnt.execute();
+            stmnt.close();
+        }
+    }
 
     /**
      * Connection wrapper to cache the {@link Connection#getCatalog} result,



Mime
View raw message