Skip to content

Commit 1ae477b

Browse files
committed
HHH-16516 no need to quote a $ except at the start of column/table name
1 parent 297db57 commit 1ae477b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ else if ( quoteOnNonIdentifierChar && !quote ) {
112112
else {
113113
for ( int i = start + 1; i < end; i++ ) {
114114
c = text.charAt( i );
115-
if ( !isLetterOrDigit( c ) && c != '_' ) {
115+
if ( !isLetterOrDigit( c ) && c != '_' && c != '$' ) {
116116
quote = true;
117117
break;
118118
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* SPDX-License-Identifier: LGPL-2.1-or-later
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.mapping.autoquote;
6+
7+
import jakarta.persistence.Column;
8+
import jakarta.persistence.Entity;
9+
import jakarta.persistence.Id;
10+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
11+
import org.hibernate.testing.orm.junit.Jpa;
12+
import org.junit.jupiter.api.Test;
13+
14+
@Jpa(annotatedClasses = SpecialCharactersTest.Simple.class)
15+
public class SpecialCharactersTest {
16+
@Test void test(EntityManagerFactoryScope scope) {
17+
scope.getEntityManagerFactory();
18+
}
19+
@Entity static class Simple {
20+
@Id
21+
long id;
22+
@Column(name="NAME$NAME")
23+
String nameWithDollar;
24+
@Column(name="$NAME")
25+
String nameWithInitialDollar;
26+
@Column(name="NAME#NAME")
27+
String nameWithHash;
28+
@Column(name="NAME NAME")
29+
String nameWithSpace;
30+
}
31+
}

0 commit comments

Comments
 (0)