HHH-6767: Added guard to ensure the DB is not SQL SErver before adding ORDER BY clause to SQL

This commit is contained in:
John Verhaeg 2011-10-24 16:19:43 -05:00
parent dfd718418c
commit b31c17b332
1 changed files with 11 additions and 9 deletions

View File

@ -50,6 +50,7 @@ import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Property; import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.Subqueries; import org.hibernate.criterion.Subqueries;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.exception.SQLGrammarException; import org.hibernate.exception.SQLGrammarException;
import org.hibernate.internal.util.SerializationHelper; import org.hibernate.internal.util.SerializationHelper;
import org.hibernate.test.hql.Animal; import org.hibernate.test.hql.Animal;
@ -212,7 +213,8 @@ public class CriteriaQueryTest extends BaseCoreFunctionalTestCase {
dc4.getExecutableCriteria( session ).list(); dc4.getExecutableCriteria( session ).list();
dc4.getExecutableCriteria( session ).addOrder( Order.asc( "stname" ) ).list(); // SQL Server doesn't normally support ORDER BY in subqueries...
if (!(getDialect() instanceof SQLServerDialect)) dc4.getExecutableCriteria(session).addOrder(Order.asc("stname")).list();
session.createCriteria(Enrolment.class, "e") session.createCriteria(Enrolment.class, "e")
.add( Subqueries.eq("Gavin King", dc4) ) .add( Subqueries.eq("Gavin King", dc4) )