Skip to content

Commit f8f1f3e

Browse files
committed
HHH-16972 move getTupleLength() off API and onto SQM type
1 parent 594608d commit f8f1f3e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/DomainType.java

-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package org.hibernate.metamodel.model.domain;
66

7-
import org.hibernate.Internal;
87
import org.hibernate.type.descriptor.java.JavaType;
98

109
/**
@@ -47,9 +46,4 @@ public interface DomainType<J> {
4746
* However, using the string allows for dynamic models.
4847
*/
4948
String getTypeName();
50-
51-
@Internal
52-
default int getTupleLength() {
53-
return 1;
54-
}
5549
}

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EmbeddableTypeImpl.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.hibernate.metamodel.model.domain.ManagedDomainType;
1515
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
1616
import org.hibernate.query.sqm.SqmPathSource;
17+
import org.hibernate.query.sqm.tree.domain.SqmDomainType;
1718
import org.hibernate.query.sqm.tree.domain.SqmPath;
1819
import org.hibernate.query.sqm.tree.domain.SqmEmbeddableDomainType;
1920
import org.hibernate.type.descriptor.java.JavaType;
@@ -48,10 +49,11 @@ public PersistenceType getPersistenceType() {
4849
return PersistenceType.EMBEDDABLE;
4950
}
5051

52+
@Override
5153
public int getTupleLength() {
5254
int count = 0;
5355
for ( var attribute : getSingularAttributes() ) {
54-
count += ( (DomainType<?>) attribute.getType() ).getTupleLength();
56+
count += ( (SqmDomainType<?>) attribute.getType() ).getTupleLength();
5557
}
5658
return count;
5759
}

hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmDomainType.java

+4
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ public interface SqmDomainType<T>
1717
default String getTypeName() {
1818
return SqmExpressible.super.getTypeName();
1919
}
20+
21+
default int getTupleLength() {
22+
return 1;
23+
}
2024
}

hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmSelectableNode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import java.util.function.Consumer;
88
import jakarta.persistence.criteria.Selection;
99

10-
import org.hibernate.metamodel.model.domain.DomainType;
1110
import org.hibernate.query.criteria.JpaSelection;
1211
import org.hibernate.query.sqm.tree.SqmCopyContext;
1312
import org.hibernate.query.sqm.tree.SqmTypedNode;
13+
import org.hibernate.query.sqm.tree.domain.SqmDomainType;
1414

1515
/**
1616
* Defines a SQM AST node that can be used as a selection in the query,
@@ -33,7 +33,7 @@ public interface SqmSelectableNode<T> extends JpaSelection<T>, SqmTypedNode<T> {
3333
SqmSelectableNode<T> copy(SqmCopyContext context);
3434

3535
default Integer getTupleLength() {
36-
final DomainType<T> sqmType = getNodeType() == null ? null : getNodeType().getSqmType();
36+
final SqmDomainType<T> sqmType = getNodeType() == null ? null : getNodeType().getSqmType();
3737
return sqmType == null ? 1 : sqmType.getTupleLength();
3838
}
3939
}

0 commit comments

Comments
 (0)