You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by ht...@apache.org on 2014/10/14 17:21:31 UTC
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/
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(".éå¡ãã©ã°");
+ }
+}