Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3755,12 +3755,23 @@ protected Expression createLateralJoinExpression(
creationContext
)
);
final String compatibleTableExpression;
if ( modelPart instanceof BasicValuedModelPart ) {
compatibleTableExpression = ( (BasicValuedModelPart) modelPart ).getContainingTableExpression();
}
else if ( modelPart instanceof EmbeddableValuedModelPart ) {
compatibleTableExpression = ( (EmbeddableValuedModelPart) modelPart ).getContainingTableExpression();
}
else {
compatibleTableExpression = null;
}
lateralTableGroup = new QueryPartTableGroup(
queryPath,
null,
subQuerySpec,
identifierVariable,
columnNames,
compatibleTableExpression,
true,
false,
creationContext.getSessionFactory()
Expand Down Expand Up @@ -3801,7 +3812,12 @@ protected Expression createLateralJoinExpression(
}
parentFromClauseAccess.registerTableGroup( lateralTableGroup.getNavigablePath(), lateralTableGroup );
if ( jdbcTypeCount == 1 ) {
return resultColumnReferences.get( 0 );
return new BasicValuedPathInterpretation<>(
resultColumnReferences.get( 0 ),
queryPath,
(BasicValuedModelPart) modelPart,
lateralTableGroup
);
}
else {
return new SqlTuple( resultColumnReferences, modelPart );
Expand All @@ -3813,14 +3829,19 @@ protected Expression createLateralJoinExpression(
}
final QueryPartTableReference tableReference = (QueryPartTableReference) lateralTableGroup.getPrimaryTableReference();
if ( jdbcTypeCount == 1 ) {
return new ColumnReference(
return new BasicValuedPathInterpretation<>(
new ColumnReference(
identifierVariable,
tableReference.getColumnNames().get( 0 ),
false,
null,
null,
modelPart.getJdbcMappings().get( 0 ),
creationContext.getSessionFactory()
),
queryPath,
(BasicValuedModelPart) modelPart,
lateralTableGroup
);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

import org.hibernate.engine.spi.SessionFactoryImplementor;
Expand All @@ -22,6 +23,7 @@
public class QueryPartTableGroup extends AbstractTableGroup {

private final QueryPartTableReference queryPartTableReference;
private final String compatibleTableExpression;

public QueryPartTableGroup(
NavigablePath navigablePath,
Expand All @@ -32,6 +34,28 @@ public QueryPartTableGroup(
boolean lateral,
boolean canUseInnerJoins,
SessionFactoryImplementor sessionFactory) {
this(
navigablePath,
tableGroupProducer,
queryPart,
sourceAlias,
columnNames,
null,
lateral,
canUseInnerJoins,
sessionFactory
);
}

public QueryPartTableGroup(
NavigablePath navigablePath,
TableGroupProducer tableGroupProducer,
QueryPart queryPart,
String sourceAlias,
List<String> columnNames,
String compatibleTableExpression, boolean lateral,
boolean canUseInnerJoins,
SessionFactoryImplementor sessionFactory) {
super(
canUseInnerJoins,
navigablePath,
Expand All @@ -40,6 +64,7 @@ public QueryPartTableGroup(
null,
sessionFactory
);
this.compatibleTableExpression = compatibleTableExpression;
this.queryPartTableReference = new QueryPartTableReference(
queryPart,
sourceAlias,
Expand All @@ -60,7 +85,7 @@ protected TableReference getTableReferenceInternal(
String tableExpression,
boolean allowFkOptimization,
boolean resolve) {
if ( tableExpression == null ) {
if ( Objects.equals( tableExpression, compatibleTableExpression ) ) {
return getPrimaryTableReference();
}
for ( TableGroupJoin tableGroupJoin : getNestedTableGroupJoins() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import org.hibernate.QueryException;
import org.hibernate.dialect.DerbyDialect;

import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MariaDBDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TiDBDialect;
import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.hibernate.testing.orm.domain.gambit.EntityOfBasics;
Expand Down Expand Up @@ -94,14 +91,6 @@ public void testIdVersionFunctions(SessionFactoryScope scope) {
}

@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(HSQLDialect.class)
@RequiresDialect(DerbyDialect.class)
@RequiresDialect(MySQLDialect.class)
@RequiresDialect(SybaseDialect.class)
@RequiresDialect(MariaDBDialect.class)
@RequiresDialect(TiDBDialect.class)
// it's failing on the other dialects due to a bug in query translator
public void testMaxMinSumIndexElement(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Expand Down Expand Up @@ -133,14 +122,6 @@ public void testMaxMinSumIndexElement(SessionFactoryScope scope) {
}

@Test
@RequiresDialect(H2Dialect.class)
@RequiresDialect(HSQLDialect.class)
@RequiresDialect(DerbyDialect.class)
@RequiresDialect(MySQLDialect.class)
@RequiresDialect(SybaseDialect.class)
@RequiresDialect(MariaDBDialect.class)
@RequiresDialect(TiDBDialect.class)
// it's failing on the other dialects due to a bug in query translator
public void testMaxindexMaxelement(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Expand Down