Skip to content

Commit

Permalink
HHH-13554 : QueryAndSQLTest.testNativeQueryWithFormulaAttributeWithou…
Browse files Browse the repository at this point in the history
…tAlias() fails on Oracle, MSSQL, Sybase, DB2

(cherry picked from commit 2a154cb)
  • Loading branch information
gbadner committed Aug 9, 2019
1 parent cc164e4 commit 19fdd06
Showing 1 changed file with 10 additions and 2 deletions.
Expand Up @@ -31,7 +31,6 @@
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.stat.Statistics;
import org.hibernate.type.StandardBasicTypes;

import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
Expand Down Expand Up @@ -95,7 +94,16 @@ public void testNativeQueryWithFormulaAttribute() {

@Test
public void testNativeQueryWithFormulaAttributeWithoutAlias() {
String sql = "select TABLE_NAME , sysdate() from all_tables where TABLE_NAME = 'AUDIT_ACTIONS' ";
SQLFunction dateFunction = getDialect().getFunctions().get( "current_date" );
String dateFunctionRendered = dateFunction.render(
null,
java.util.Collections.EMPTY_LIST,
sessionFactory()
);
String sql = String.format(
"select TABLE_NAME , %s from all_tables where TABLE_NAME = 'AUDIT_ACTIONS' ",
dateFunctionRendered
);
Session s = openSession();
s.beginTransaction();
s.createSQLQuery( sql ).addEntity( "t", AllTables.class ).list();
Expand Down

0 comments on commit 19fdd06

Please sign in to comment.