diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java index e527f954a..3fe5fb481 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierRule.java @@ -176,7 +176,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; } } @@ -184,7 +184,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; } } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java new file mode 100644 index 000000000..c252d8767 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/MyDBCSEntity.java @@ -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.閉塞フラグ = 閉塞フラグ; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java new file mode 100644 index 000000000..85dee0057 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/dbcs/TestDBCS.java @@ -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(".閉塞フラグ"); + } +}