diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/Country.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/Country.java new file mode 100755 index 0000000000..3a2b1023a4 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/Country.java @@ -0,0 +1,19 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.criteria.limitexpression; + +public class Country { + private String code; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/LimitExpressionTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/LimitExpressionTest.java new file mode 100644 index 0000000000..b3f0a2e990 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/LimitExpressionTest.java @@ -0,0 +1,65 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.criteria.limitexpression; + +import java.util.Arrays; +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.criterion.Restrictions; + +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; + +import static junit.framework.TestCase.fail; + +/** + * @author Andrea Boriero + */ +@TestForIssue(jiraKey = "HHH-915") +@RequiresDialectFeature( + value = DialectChecks.SupportLimitCheck.class, + comment = "Dialect does not support limit" +) +public class LimitExpressionTest extends BaseNonConfigCoreFunctionalTestCase { + + @Override + public String[] getMappings() { + return new String[] {"criteria/limitexpression/domain.hbm.xml"}; + } + + @Override + public String getCacheConcurrencyStrategy() { + return null; + } + + @org.junit.Test + public void testWithFetchJoin() { + Session session = openSession(); + Transaction transaction = session.beginTransaction(); + try { + List stateCodes = Arrays.asList( "DC", "CT" ); + Criteria crit = session.createCriteria( Person.class ); + crit.createCriteria( "states" ).add( Restrictions.in( "code", stateCodes ) ); + crit.setMaxResults( 10 ); + crit.list(); + + transaction.commit(); + } + catch (Exception e) { + transaction.rollback(); + fail(e.getMessage()); + } + finally { + session.close(); + } + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/Person.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/Person.java new file mode 100755 index 0000000000..458b8b77e0 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/Person.java @@ -0,0 +1,41 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.criteria.limitexpression; + +import java.util.Set; + +public class Person { + private Long id; + private Set states; + private Set countries; + + public Set getStates() { + return states; + } + + public void setStates(Set states) { + this.states = states; + } + + public Set getCountries() { + return countries; + } + + public void setCountries(Set countries) { + this.countries = countries; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/UsState.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/UsState.java new file mode 100755 index 0000000000..0776d4f7cf --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/UsState.java @@ -0,0 +1,19 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.criteria.limitexpression; + +public class UsState { + private String code; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/domain.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/domain.hbm.xml new file mode 100755 index 0000000000..f7456ae0bf --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/limitexpression/domain.hbm.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +