HHH-14567 Test enabling filters after query creation but before query execution
This commit is contained in:
parent
7ef27cbb26
commit
96544d94a8
|
@ -31,6 +31,7 @@ import org.hibernate.dialect.IngresDialect;
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
import org.hibernate.query.Query;
|
||||||
import org.hibernate.transform.DistinctRootEntityResultTransformer;
|
import org.hibernate.transform.DistinctRootEntityResultTransformer;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
@ -38,6 +39,7 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
@ -213,6 +215,29 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
testData.release();
|
testData.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-14567")
|
||||||
|
public void testHqlFiltersAppliedAfterQueryCreation() {
|
||||||
|
TestData testData = new TestData();
|
||||||
|
testData.prepare();
|
||||||
|
|
||||||
|
try {
|
||||||
|
inTransaction( session -> {
|
||||||
|
Query<Salesperson> query = session.createQuery(
|
||||||
|
"select s from Salesperson s",
|
||||||
|
Salesperson.class
|
||||||
|
);
|
||||||
|
assertThat( query.list() ).hasSize( 2 );
|
||||||
|
|
||||||
|
session.enableFilter( "region" ).setParameter( "region", "APAC" );
|
||||||
|
assertThat( query.list() ).hasSize( 1 );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
testData.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFiltersWithCustomerReadAndWrite() {
|
public void testFiltersWithCustomerReadAndWrite() {
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
|
@ -24,6 +24,13 @@ public class Salesperson {
|
||||||
private Department department;
|
private Department department;
|
||||||
private Set orders = new HashSet();
|
private Set orders = new HashSet();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Salesperson#" + id + "{"
|
||||||
|
+ ", name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue