Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-9794 - Replace string with preceding comma is not replacing strin…
…g as required (cherry picked from commit 4218f36)
- Loading branch information
Showing
2 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
hibernate-core/src/test/java/org/hibernate/test/hql/QuerySplitterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.test.hql; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
|
||
import org.hibernate.hql.internal.QuerySplitter; | ||
|
||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
public class QuerySplitterTest extends BaseNonConfigCoreFunctionalTestCase { | ||
@Test | ||
public void testQueryWithEntityNameAsStringLiteral() { | ||
final String qry = "select e from Employee a where e.name = ', Employee Number 1'"; | ||
|
||
String[] results = QuerySplitter.concreteQueries( qry, sessionFactory() ); | ||
assertEquals( 1, results.length ); | ||
assertEquals( | ||
"select e from org.hibernate.test.hql.QuerySplitterTest$Employee a where e.name = ', Employee Number 1'", | ||
results[0] | ||
); | ||
} | ||
|
||
@Override | ||
protected Class[] getAnnotatedClasses() { | ||
return new Class[] { Employee.class }; | ||
} | ||
|
||
@Entity( name = "Employee" ) | ||
@Table( name= "tabEmployees" ) | ||
public class Employee { | ||
@Id | ||
private long id; | ||
private String name; | ||
|
||
public Employee() { | ||
|
||
} | ||
|
||
public Employee(long id, String strName) { | ||
this(); | ||
this.name = strName; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String strName) { | ||
this.name = strName; | ||
} | ||
|
||
} | ||
} |