pull over "legacy 6.0" tests

This commit is contained in:
Steve Ebersole 2019-11-21 15:29:13 -06:00
parent 7576b51407
commit 04c5160e02
3 changed files with 97 additions and 6 deletions

View File

@ -84,12 +84,12 @@ import org.hibernate.query.sqm.tree.expression.SqmBinaryArithmetic;
import org.hibernate.query.sqm.tree.expression.SqmCaseSearched; import org.hibernate.query.sqm.tree.expression.SqmCaseSearched;
import org.hibernate.query.sqm.tree.expression.SqmCaseSimple; import org.hibernate.query.sqm.tree.expression.SqmCaseSimple;
import org.hibernate.query.sqm.tree.expression.SqmCollectionSize; import org.hibernate.query.sqm.tree.expression.SqmCollectionSize;
import org.hibernate.query.sqm.tree.expression.SqmParameterizedEntityType;
import org.hibernate.query.sqm.tree.expression.SqmExpression; import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.expression.SqmLiteral; import org.hibernate.query.sqm.tree.expression.SqmLiteral;
import org.hibernate.query.sqm.tree.expression.SqmLiteralNull; import org.hibernate.query.sqm.tree.expression.SqmLiteralNull;
import org.hibernate.query.sqm.tree.expression.SqmNamedParameter; import org.hibernate.query.sqm.tree.expression.SqmNamedParameter;
import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.query.sqm.tree.expression.SqmParameter;
import org.hibernate.query.sqm.tree.expression.SqmParameterizedEntityType;
import org.hibernate.query.sqm.tree.expression.SqmPathEntityType; import org.hibernate.query.sqm.tree.expression.SqmPathEntityType;
import org.hibernate.query.sqm.tree.expression.SqmPositionalParameter; import org.hibernate.query.sqm.tree.expression.SqmPositionalParameter;
import org.hibernate.query.sqm.tree.expression.SqmUnaryOperation; import org.hibernate.query.sqm.tree.expression.SqmUnaryOperation;
@ -727,6 +727,10 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre
if ( sqmFrom != null ) { if ( sqmFrom != null ) {
return sqmFrom; return sqmFrom;
} }
final DotIdentifierConsumer dotIdentifierConsumer = dotIdentifierConsumerStack.getCurrent();
dotIdentifierConsumer.consumeIdentifier( ctx.getText(), true, true );
return (SqmExpression) dotIdentifierConsumer.getConsumedPart();
} }
return (SqmExpression) ctx.expression().accept( this ); return (SqmExpression) ctx.expression().accept( this );
@ -2707,7 +2711,6 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre
// return result; // return result;
// } // }
@Override @Override
public SemanticPathPart visitDotIdentifierSequence(HqlParser.DotIdentifierSequenceContext ctx) { public SemanticPathPart visitDotIdentifierSequence(HqlParser.DotIdentifierSequenceContext ctx) {
final int numberOfContinuations = ctx.dotIdentifierSequenceContinuation().size(); final int numberOfContinuations = ctx.dotIdentifierSequenceContinuation().size();

View File

@ -157,9 +157,9 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
public List<R> performList(ExecutionContext executionContext) { public List<R> performList(ExecutionContext executionContext) {
final SharedSessionContractImplementor session = executionContext.getSession(); final SharedSessionContractImplementor session = executionContext.getSession();
if ( jdbcSelect == null ) { // if ( jdbcSelect == null ) {
// todo (6.0) : for cases where we have no "load query influencers" we could use a cached SQL AST // // todo (6.0) : for cases where we have no "load query influencers" we could use a cached SQL AST
// - this is similar to the plan for loaders // // - this is similar to the plan for loaders
final SessionFactoryImplementor sessionFactory = session.getFactory(); final SessionFactoryImplementor sessionFactory = session.getFactory();
final QueryEngine queryEngine = sessionFactory.getQueryEngine(); final QueryEngine queryEngine = sessionFactory.getQueryEngine();
@ -189,7 +189,7 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
domainParameterXref, domainParameterXref,
interpretation::getJdbcParamsBySqmParam interpretation::getJdbcParamsBySqmParam
); );
} // }
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings( final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(

View File

@ -0,0 +1,88 @@
/*
* 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 http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.test.query.hql;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.hibernate.boot.MetadataSources;
import org.hibernate.query.Query;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.domain.contacts.Contact;
import org.hibernate.testing.orm.domain.contacts.ContactsDomainModel;
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* @author Andrea Boriero
*/
@SuppressWarnings("WeakerAccess")
@TestForIssue(jiraKey = "HHH-10893")
public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
@Override
protected void applyMetadataSources(MetadataSources metadataSources) {
super.applyMetadataSources( metadataSources );
ContactsDomainModel.applyContactsModel( metadataSources );
}
@BeforeAll
public void prepareData() {
inTransaction(
session -> {
for ( int i = 0; i < 20; i++ ) {
Contact p1 = new Contact(
i,
new Contact.Name( "first[" + i + "]", "last[" + i + "]" ),
Contact.Gender.MALE,
LocalDate.now()
);
session.save( p1 );
}
}
);
}
@Test
public void testParameterListIn() {
inTransaction(
session -> {
Collection<Integer> ids = new ArrayList<>();
Query q = session.createQuery( "select id from Contact where id in (:ids) order by id" );
for ( int i = 0; i < 10; i++ ) {
ids.add( i );
}
q.setParameterList( "ids", ids );
q.list();
ids.clear();
for ( int i = 10; i < 20; i++ ) {
ids.add( i );
}
// reuse the same query, but set new collection parameter
q.setParameterList( "ids", ids );
List<Long> foundIds = q.list();
assertThat( "Wrong number of results", foundIds.size(), is( ids.size() ) );
assertThat( foundIds, is( ids ) );
}
);
}
@AfterAll
public void cleanupData() {
inTransaction( session -> session.createQuery( "delete Contact" ).executeUpdate() );
}
}