openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1631786 - in /openjpa/branches/2.2.x: openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/
Date Tue, 14 Oct 2014 15:21:31 GMT
Author: hthomann
Date: Tue Oct 14 15:21:30 2014
New Revision: 1631786

URL: http://svn.apache.org/r1631786
Log:
OPENJPA-2535: Fixed issue with DBCS characters in identifiers.

Added:
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java
Modified:
    openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java

Modified: openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java?rev=1631786&r1=1631785&r2=1631786&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java
(original)
+++ openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java
Tue Oct 14 15:21:30 2014
@@ -177,7 +177,7 @@ public class IdentifierRule {
         // Assert identifier begins with a letter
         char[] chars = identifier.toCharArray();
         if (isMustBeginWithLetter()) {
-            if (!CharUtils.isAsciiAlpha(chars[0])) {
+            if (!Character.isJavaIdentifierStart(chars[0])) {
                 return true;
             }
         }
@@ -185,7 +185,7 @@ public class IdentifierRule {
         // Iterate through chars, asserting delimiting rules 
         for (char ch : chars) {
             if (isOnlyLettersDigitsUnderscores()) {
-                if (!CharUtils.isAsciiAlphanumeric(ch) && !(ch == UNDERSCORE)) {
+                if (!Character.isJavaIdentifierPart(ch) && !(ch == UNDERSCORE)) {
                     return true;
                 }
             }

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java?rev=1631786&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java
Tue Oct 14 15:21:30 2014
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.jdbc.dbcs;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class MyDBCSEntity implements Serializable {
+    private static final long serialVersionUID = 1259199954797560098L;
+
+    @Id
+    private String 業務id;
+    private String 閉塞フラグ;
+
+    public String get業務id() {
+        return this.業務id;
+    }
+
+    public void set業務id(String 業務id) {
+        this.業務id = 業務id;
+    }
+
+    public String get閉塞フラグ() {
+        return this.閉塞フラグ;
+    }
+
+    public void set閉塞フラグ(String 閉塞フラグ)
{
+        this.閉塞フラグ = 閉塞フラグ;
+    }
+}

Added: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java?rev=1631786&view=auto
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java
(added)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java
Tue Oct 14 15:21:30 2014
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.jdbc.dbcs;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+/*
+ * This test will verify that when a double byte charater set (DBCS) character
+ * is used in an entity, that quotes are not added to the identifier.  See
+ * JIRA OPENJPA-2535.
+ */
+public class TestDBCS extends SQLListenerTestCase {
+
+    public void setUp() {
+        setUp(MyDBCSEntity.class);
+    }
+
+    public void test() {
+        EntityManager em = emf.createEntityManager();
+        String qStr = "SELECT m FROM MyDBCSEntity m WHERE m.閉塞フラグ
= '0' ORDER BY m.業務id";
+
+        Query query = em.createQuery(qStr);
+        resetSQL();
+        query.getResultList();
+
+        //Prior to OPENJPA-2535 the identifies with DBCS characters would be quoted.
+        //Verify the identifies don't contain quotes.
+        assertContainsSQL(".業務id");
+        assertContainsSQL(".閉塞フラグ");
+    }
+}



Mime
View raw message