openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r707222 - in /openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DBDictionary.java SybaseDictionary.java
Date Wed, 22 Oct 2008 23:30:32 GMT
Author: faywang
Date: Wed Oct 22 16:30:31 2008
New Revision: 707222

URL: http://svn.apache.org/viewvc?rev=707222&view=rev
Log:
OPENJPA-745: raise exception when the string to be inserted
or updated is longer than the column length.

Modified:
    openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java

Modified: openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=707222&r1=707221&r2=707222&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Oct 22 16:30:31 2008
@@ -199,6 +199,7 @@
     public String selectWords = null;
     public String fixedSizeTypeNames = null;
     public String schemaCase = SCHEMA_CASE_UPPER;
+    public boolean setStringRightTruncationOn = true;
 
     // sql
     public String validationSQL = null;

Modified: openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java?rev=707222&r1=707221&r2=707222&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
(original)
+++ openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
Wed Oct 22 16:30:31 2008
@@ -266,7 +266,18 @@
 
     public Connection decorate(Connection conn)
         throws SQLException {
-        return new SybaseConnection(super.decorate(conn));
+        conn = super.decorate(conn);
+        // 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();
+        }
+        return new SybaseConnection(conn);
     }
 
     /**



Mime
View raw message