HHH-17499 Fix tuple length check for positional parameters
This commit is contained in:
parent
0440dd5a8c
commit
d3027907c2
|
@ -69,4 +69,9 @@ public abstract class AbstractSqmParameter<T> extends AbstractSqmExpression<T> i
|
|||
public Class<T> getParameterType() {
|
||||
return this.getNodeType().getExpressibleJavaType().getJavaTypeClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getTupleLength() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,9 +88,4 @@ public class SqmNamedParameter<T> extends AbstractSqmParameter<T> {
|
|||
? getName().compareTo( ( (SqmNamedParameter<?>) anotherParameter ).getName() )
|
||||
: -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getTupleLength() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.stat.spi.StatisticsImplementor;
|
|||
import org.hibernate.testing.orm.domain.gambit.EmbeddedIdEntity;
|
||||
import org.hibernate.testing.orm.domain.gambit.EmbeddedIdEntity.EmbeddedIdEntityId;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
@ -120,4 +121,36 @@ public class EmbeddedIdEntityTest {
|
|||
);
|
||||
assertThat( statistics.getPrepareStatementCount(), is( 1L ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@Jira( "https://hibernate.atlassian.net/browse/HHH-17499" )
|
||||
public void testNamedParameterComparison(SessionFactoryScope scope) {
|
||||
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
|
||||
statistics.clear();
|
||||
scope.inTransaction( session -> {
|
||||
final EmbeddedIdEntity loaded = session.createQuery(
|
||||
"select e FROM EmbeddedIdEntity e WHERE e.id = :id",
|
||||
EmbeddedIdEntity.class
|
||||
).setParameter( "id", entityId ).getSingleResult();
|
||||
assertThat( loaded.getData(), is( "test" ) );
|
||||
assertThat( loaded.getId(), equalTo( entityId ) );
|
||||
} );
|
||||
assertThat( statistics.getPrepareStatementCount(), is( 1L ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@Jira( "https://hibernate.atlassian.net/browse/HHH-17499" )
|
||||
public void testPositionalParameterComparison(SessionFactoryScope scope) {
|
||||
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
|
||||
statistics.clear();
|
||||
scope.inTransaction( session -> {
|
||||
final EmbeddedIdEntity loaded = session.createQuery(
|
||||
"select e FROM EmbeddedIdEntity e WHERE e.id = ?1",
|
||||
EmbeddedIdEntity.class
|
||||
).setParameter( 1, entityId ).getSingleResult();
|
||||
assertThat( loaded.getData(), is( "test" ) );
|
||||
assertThat( loaded.getId(), equalTo( entityId ) );
|
||||
} );
|
||||
assertThat( statistics.getPrepareStatementCount(), is( 1L ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue