HHH-5946 - Tests for not equals operations expecting QuerySyntaxException require dialect does not support row value constructor syntax

This commit is contained in:
Andrea Boriero 2015-11-14 14:33:16 +00:00
parent 5559b596e6
commit 12050ae7e8
3 changed files with 51 additions and 38 deletions

View File

@ -18,6 +18,9 @@ import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.hql.internal.ast.QuerySyntaxException; import org.hibernate.hql.internal.ast.QuerySyntaxException;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.SkipForDialects;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -221,16 +224,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase {
*/ */
@Test( expected = QuerySyntaxException.class ) @Test( expected = QuerySyntaxException.class )
@TestForIssue( jiraKey = "HHH-5946" ) @TestForIssue( jiraKey = "HHH-5946" )
@RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class )
public void testLessThanOperator() { public void testLessThanOperator() {
final Session s = openSession(); final Session s = openSession();
s.getTransaction().begin(); try {
final Query q = s.createQuery( "from Transaction where value < :amount" );
final Query q = s.createQuery( "from Transaction where value < :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) );
q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); q.list();
q.list(); }
finally {
s.getTransaction().commit(); s.close();
s.close(); }
} }
/** /**
@ -239,16 +243,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase {
*/ */
@Test( expected = QuerySyntaxException.class ) @Test( expected = QuerySyntaxException.class )
@TestForIssue( jiraKey = "HHH-5946" ) @TestForIssue( jiraKey = "HHH-5946" )
@RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class )
public void testLessOrEqualOperator() { public void testLessOrEqualOperator() {
final Session s = openSession(); final Session s = openSession();
s.getTransaction().begin(); try {
final Query q = s.createQuery( "from Transaction where value <= :amount" );
final Query q = s.createQuery( "from Transaction where value <= :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) );
q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); q.list();
q.list(); }
finally {
s.getTransaction().commit(); s.close();
s.close(); }
} }
/** /**
@ -257,16 +262,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase {
*/ */
@Test( expected = QuerySyntaxException.class ) @Test( expected = QuerySyntaxException.class )
@TestForIssue( jiraKey = "HHH-5946" ) @TestForIssue( jiraKey = "HHH-5946" )
@RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class )
public void testGreaterThanOperator() { public void testGreaterThanOperator() {
final Session s = openSession(); final Session s = openSession();
s.getTransaction().begin(); try {
final Query q = s.createQuery( "from Transaction where value > :amount" );
final Query q = s.createQuery( "from Transaction where value > :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) );
q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); q.list();
q.list(); }
finally {
s.getTransaction().commit(); s.close();
s.close(); }
} }
/** /**
@ -275,16 +281,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase {
*/ */
@Test( expected = QuerySyntaxException.class ) @Test( expected = QuerySyntaxException.class )
@TestForIssue( jiraKey = "HHH-5946" ) @TestForIssue( jiraKey = "HHH-5946" )
@RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class )
public void testGreaterOrEqualOperator() { public void testGreaterOrEqualOperator() {
final Session s = openSession(); final Session s = openSession();
s.getTransaction().begin(); try {
final Query q = s.createQuery( "from Transaction where value >= :amount" );
final Query q = s.createQuery( "from Transaction where value >= :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) );
q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); q.list();
q.list(); }
finally {
s.getTransaction().commit(); s.close();
s.close(); }
} }
} }

View File

@ -27,12 +27,12 @@
<column name="currency" not-null="true"/> <column name="currency" not-null="true"/>
</property> </property>
<property name="timestamp" type="userDateTime"> <property name="timestamp" type="userDateTime">
<column name="year"/> <column name="ts_year"/>
<column name="month"/> <column name="ts_month"/>
<column name="day"/> <column name="ts_day"/>
<column name="hour"/> <column name="ts_hour"/>
<column name="minute"/> <column name="ts_minute"/>
<column name="second"/> <column name="ts_second"/>
</property> </property>
</class> </class>

View File

@ -177,4 +177,10 @@ abstract public class DialectChecks {
return dialect.canCreateCatalog(); return dialect.canCreateCatalog();
} }
} }
public static class DoesNotSupportRowValueConstructorSyntax implements DialectCheck {
public boolean isMatch(Dialect dialect) {
return dialect.supportsRowValueConstructorSyntax() == false;
}
}
} }