mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 17:15:02 +00:00
HHH-11568 - Added test case.
This commit is contained in:
parent
9ae391436a
commit
4bd5c8a730
@ -15,6 +15,7 @@
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
@ -63,11 +64,13 @@
|
||||
import antlr.RecognitionException;
|
||||
import antlr.collections.AST;
|
||||
|
||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests cases where the AST based query translator and the 'classic' query translator generate identical SQL.
|
||||
@ -107,6 +110,38 @@ protected void cleanupTest() throws Exception {
|
||||
super.cleanupTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-2187")
|
||||
public void testBogusQuery() {
|
||||
try {
|
||||
QueryTranslatorImpl translator = createNewQueryTranslator( "bogus" );
|
||||
fail( "This should have failed with a QueryException" );
|
||||
}
|
||||
catch ( Throwable t ) {
|
||||
assertTyping( QueryException.class, t );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-2187")
|
||||
public void testBogusCreateQuery() {
|
||||
Session session = openSession();
|
||||
try {
|
||||
session.beginTransaction();
|
||||
session.createQuery( "Bogus" );
|
||||
fail( "This should have failed with an IllegalArgumentException" );
|
||||
}
|
||||
catch ( IllegalArgumentException e ) {
|
||||
if ( session.getTransaction().isActive() ) {
|
||||
session.getTransaction().rollback();
|
||||
}
|
||||
assertTyping( QueryException.class, e.getCause() );
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModulo() {
|
||||
assertTranslation( "from Animal a where a.bodyWeight % 2 = 0" );
|
||||
@ -133,6 +168,7 @@ public void testRowValueConstructorSyntaxInInList2() {
|
||||
PostgreSQL81Dialect.class,
|
||||
MySQLDialect.class
|
||||
} )
|
||||
|
||||
public void testRowValueConstructorSyntaxInInListBeingTranslated() {
|
||||
QueryTranslatorImpl translator = createNewQueryTranslator("from LineItem l where l.id in (?)");
|
||||
assertInExist("'in' should be translated to 'and'", false, translator);
|
||||
|
Loading…
x
Reference in New Issue
Block a user