forked from hibernate/hibernate-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-18089 Support bracket syntax with string types
- Loading branch information
Showing
7 changed files
with
204 additions
and
66 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
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
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
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
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
62 changes: 62 additions & 0 deletions
62
hibernate-core/src/test/java/org/hibernate/orm/test/hql/StringBracketSyntaxTest.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,62 @@ | ||
package org.hibernate.orm.test.hql; | ||
|
||
import org.hibernate.testing.orm.domain.StandardDomainModel; | ||
import org.hibernate.testing.orm.domain.gambit.BasicEntity; | ||
import org.hibernate.testing.orm.junit.DomainModel; | ||
import org.hibernate.testing.orm.junit.JiraKey; | ||
import org.hibernate.testing.orm.junit.SessionFactory; | ||
import org.hibernate.testing.orm.junit.SessionFactoryScope; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
@DomainModel(standardModels = StandardDomainModel.GAMBIT) | ||
@SessionFactory | ||
@JiraKey("HHH-18089") | ||
public class StringBracketSyntaxTest { | ||
|
||
@BeforeAll | ||
public void setUp(SessionFactoryScope scope) { | ||
scope.inTransaction( | ||
session -> { | ||
BasicEntity entity = new BasicEntity(1, "Hello World"); | ||
session.persist( entity ); | ||
} | ||
); | ||
} | ||
|
||
@AfterAll | ||
public void tearDown(SessionFactoryScope scope) { | ||
scope.inTransaction( | ||
session -> { | ||
session.createMutationQuery( "delete from BasicEntity" ).executeUpdate(); | ||
} | ||
); | ||
} | ||
|
||
@Test | ||
public void testCharAtSyntax(SessionFactoryScope scope) { | ||
scope.inTransaction( | ||
session -> { | ||
Character firstChar = session.createQuery( "select e.data[1] from BasicEntity e", Character.class ) | ||
.getSingleResult(); | ||
assertThat( firstChar ).isEqualTo( 'H' ); | ||
} | ||
); | ||
} | ||
|
||
@Test | ||
public void testSubstringSyntax(SessionFactoryScope scope) { | ||
scope.inTransaction( | ||
session -> { | ||
String substring = session.createQuery( "select e.data[1:6] from BasicEntity e", String.class ) | ||
.getSingleResult(); | ||
assertThat( substring ).isEqualTo( "Hello " ); | ||
} | ||
); | ||
} | ||
|
||
|
||
} |
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