mirror of https://github.com/apache/openjpa.git
OPENJPA-2535: Fixed issue with DBCS characters in identifiers - merged from 2.2.x commit.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1631860 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3235030257
commit
b6eee24112
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.閉塞フラグ = 閉塞フラグ;
|
||||
}
|
||||
}
|
|
@ -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(".閉塞フラグ");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue