You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by fa...@apache.org on 2008/10/23 01:30:32 UTC
svn commit: r707222 - in
/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql:
DBDictionary.java SybaseDictionary.java
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);
}
/**