6 - SQM based on JPA type system
- Continued work on mapping model and conversion from SQM to SQL. Currently flushing out mapping model - how expressive do we want this to be? Do we really want to re-use the walking contracts? Or create a new SPI/impls based on MappingModelExpressable?
This commit is contained in:
parent
0c66f23af2
commit
7a82dcf22b
|
@ -1,149 +0,0 @@
|
|||
= Type System
|
||||
|
||||
The Hibernate "type system" is multi-layered....
|
||||
|
||||
|
||||
== JavaTypeDescriptor
|
||||
|
||||
At the lowest level we have `JavaTypeDescriptor` which describes information about Java types
|
||||
(`Class`). This level makes no distinctions based about the nature of the type. E.g. it does
|
||||
not understand that `Person` is an entity.
|
||||
|
||||
|
||||
== Domain type system (JPA/SQM)
|
||||
|
||||
The JPA type system is an "unmapped" model, meaning that it has no mapping information -
|
||||
no references to tables, columns, etc. The base contract for Hibernate's extension to the
|
||||
JPA model is `org.hibernate.metamodel.model.domain.DomainType`.
|
||||
|
||||
Hibernate's Semantic Query Model (SQM) is defined in terms of these JPA type extensions,
|
||||
through the `org.hibernate.query.sqm.SqmExpressable` contract allowing parts of the application's
|
||||
domain model to be used as part of an SQM tree.
|
||||
|
||||
|
||||
[plantuml,SqmTypeSystem,png]
|
||||
.Domain (JPA/SQM) type system
|
||||
....
|
||||
@startuml
|
||||
skinparam handwritten true
|
||||
|
||||
interface DomainType
|
||||
interface SimpleDomainType
|
||||
interface BasicDomainType
|
||||
interface AnyMappingDomainType
|
||||
interface ManagedDomainType
|
||||
interface EmbeddableDomainType
|
||||
interface IdentifiableDomainType
|
||||
interface EntityDomainType
|
||||
interface MappedSuperclassDomainType
|
||||
|
||||
interface SqmExpressable
|
||||
interface SqmPathSource
|
||||
interface PersistentAttribute
|
||||
interface SingularPersistentAttribute
|
||||
interface PluralPersistentAttribute
|
||||
|
||||
DomainType <|-- SimpleDomainType
|
||||
SimpleDomainType <|-- BasicDomainType
|
||||
SimpleDomainType <|-- AnyMappingDomainType
|
||||
SimpleDomainType <|-- ManagedDomainType
|
||||
ManagedDomainType <|-- EmbeddableDomainType
|
||||
ManagedDomainType <|-- IdentifiableDomainType
|
||||
IdentifiableDomainType <|-- MappedSuperclassDomainType
|
||||
IdentifiableDomainType <|-- EntityDomainType
|
||||
|
||||
SqmExpressable <|-- DomainType
|
||||
SqmExpressable <|-- SqmPathSource
|
||||
|
||||
SqmPathSource <|-- EntityDomainType
|
||||
SqmPathSource <|-- PersistentAttribute
|
||||
|
||||
PersistentAttribute <|-- SingularPersistentAttribute
|
||||
PersistentAttribute <|-- PluralPersistentAttribute
|
||||
|
||||
@enduml
|
||||
....
|
||||
|
||||
|
||||
|
||||
== Mapping model
|
||||
|
||||
TBC...
|
||||
|
||||
[plantuml,SqmTypeSystem,png]
|
||||
.Mapping type system
|
||||
....
|
||||
@startuml
|
||||
skinparam handwritten true
|
||||
|
||||
interface ValueMapping
|
||||
interface BasicType
|
||||
interface ModelPart
|
||||
interface ModelPartContainer
|
||||
|
||||
ValueMapping <|-- BasicType
|
||||
ValueMapping <|-- ModelPart
|
||||
ModelPartContainer <|-- EntityMapping
|
||||
ModelPartContainer <|-- EmbeddableMapping
|
||||
ModelPart <|-- EmbeddableMapping
|
||||
ModelPart <|-- AttributeMapping
|
||||
ModelPart <|-- EntityIdentifierMapping
|
||||
ModelPart <|-- EntityVersionMapping
|
||||
ModelPart <|-- EntityDiscriminatorMapping
|
||||
|
||||
|
||||
@enduml
|
||||
....
|
||||
|
||||
[source,JAVA]
|
||||
----
|
||||
interface ValueMapping {
|
||||
Type getMappingType();
|
||||
<X> X getCapability(Class<X> capabilityType);
|
||||
...
|
||||
}
|
||||
|
||||
interface ModelPart extends ValueMapping {
|
||||
<T> DomainResult<T> createDomainResult(...);
|
||||
void applySqlSelections(...);
|
||||
...
|
||||
}
|
||||
|
||||
interface ModelPartContainer extends ValueMapping {
|
||||
void visitSubMappings(Consumer<ModelPart> action);
|
||||
ModelPart findSubPart(String name);
|
||||
ModelPart resolveSubPart(String path);
|
||||
}
|
||||
|
||||
interface EntityMapping extends ModelPartContainer {
|
||||
default EntityPersister getEntityPersister() {
|
||||
return getCapability( EntityPersister.class );
|
||||
}
|
||||
|
||||
default EntityIdentifierMapping getIdentifierMapping() {
|
||||
return getCapability( EntityIdentifierMapping.class );
|
||||
}
|
||||
|
||||
default EntityVersionMapping getVersionMapping() {
|
||||
return getCapability( EntityVersionMapping.class );
|
||||
}
|
||||
|
||||
default EntityDiscriminatorMapping getDiscriminatorMapping() {
|
||||
return getCapability( EntityDiscriminatorMapping.class );
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
interface EmbeddableMapping extends ModelPart, ModelPartContainer {
|
||||
...
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
`org.hibernate.metamodel.model.mapping` contract corollaries in `org.hibernate.persister.walking`:
|
||||
|
||||
EntityMapping::EntityDefinition
|
||||
EmbeddableMapping::CompositionDefinition
|
||||
AttributeMapping::AttributeDefinition
|
||||
EntityIdentifierMapping::EntityIdentifierDefinition
|
|
@ -0,0 +1,53 @@
|
|||
= Domain type system (JPA/SQM)
|
||||
|
||||
The JPA type system is an "unmapped" model, meaning that it has no mapping information -
|
||||
no references to tables, columns, etc. The base contract for Hibernate's extension to the
|
||||
JPA model is `org.hibernate.metamodel.model.domain.DomainType`.
|
||||
|
||||
Hibernate's Semantic Query Model (SQM) is defined in terms of these JPA type extensions,
|
||||
through the `org.hibernate.query.sqm.SqmExpressable` contract allowing parts of the application's
|
||||
domain model to be used as part of an SQM tree.
|
||||
|
||||
|
||||
[plantuml,SqmTypeSystem,png]
|
||||
.Domain (JPA/SQM) type system
|
||||
....
|
||||
@startuml
|
||||
skinparam handwritten true
|
||||
|
||||
interface DomainType
|
||||
interface SimpleDomainType
|
||||
interface BasicDomainType
|
||||
interface AnyMappingDomainType
|
||||
interface ManagedDomainType
|
||||
interface EmbeddableDomainType
|
||||
interface IdentifiableDomainType
|
||||
interface EntityDomainType
|
||||
interface MappedSuperclassDomainType
|
||||
|
||||
interface SqmExpressable
|
||||
interface SqmPathSource
|
||||
interface PersistentAttribute
|
||||
interface SingularPersistentAttribute
|
||||
interface PluralPersistentAttribute
|
||||
|
||||
DomainType <|-- SimpleDomainType
|
||||
SimpleDomainType <|-- BasicDomainType
|
||||
SimpleDomainType <|-- AnyMappingDomainType
|
||||
SimpleDomainType <|-- ManagedDomainType
|
||||
ManagedDomainType <|-- EmbeddableDomainType
|
||||
ManagedDomainType <|-- IdentifiableDomainType
|
||||
IdentifiableDomainType <|-- MappedSuperclassDomainType
|
||||
IdentifiableDomainType <|-- EntityDomainType
|
||||
|
||||
SqmExpressable <|-- DomainType
|
||||
SqmExpressable <|-- SqmPathSource
|
||||
|
||||
SqmPathSource <|-- EntityDomainType
|
||||
SqmPathSource <|-- PersistentAttribute
|
||||
|
||||
PersistentAttribute <|-- SingularPersistentAttribute
|
||||
PersistentAttribute <|-- PluralPersistentAttribute
|
||||
|
||||
@enduml
|
||||
....
|
|
@ -0,0 +1,95 @@
|
|||
= Mapping model
|
||||
|
||||
[plantuml,SqmTypeSystem,png]
|
||||
.Mapping type system
|
||||
....
|
||||
@startuml
|
||||
skinparam handwritten true
|
||||
|
||||
interface MappingType
|
||||
|
||||
interface ValueMapping
|
||||
interface BasicType
|
||||
interface ModelPart
|
||||
interface ModelPartContainer
|
||||
|
||||
MappingType <|--
|
||||
|
||||
ValueMapping <|-- BasicType
|
||||
ValueMapping <|-- ModelPart
|
||||
ModelPartContainer <|-- EntityMapping
|
||||
ModelPartContainer <|-- EmbeddableMapping
|
||||
ModelPart <|-- EmbeddableMapping
|
||||
ModelPart <|-- AttributeMapping
|
||||
ModelPart <|-- EntityIdentifierMapping
|
||||
ModelPart <|-- EntityVersionMapping
|
||||
ModelPart <|-- EntityDiscriminatorMapping
|
||||
|
||||
|
||||
@enduml
|
||||
....
|
||||
|
||||
[source,JAVA]
|
||||
----
|
||||
interface ValueMapping {
|
||||
Type getMappingType();
|
||||
<X> X getCapability(Class<X> capabilityType);
|
||||
...
|
||||
}
|
||||
|
||||
interface ModelPart extends ValueMapping {
|
||||
<T> DomainResult<T> createDomainResult(...);
|
||||
void applySqlSelections(...);
|
||||
...
|
||||
}
|
||||
|
||||
interface ModelPartContainer extends ValueMapping {
|
||||
void visitSubMappings(Consumer<ModelPart> action);
|
||||
ModelPart findSubPart(String name);
|
||||
ModelPart resolveSubPart(String path);
|
||||
}
|
||||
|
||||
interface EntityMapping extends ModelPartContainer {
|
||||
default EntityPersister getEntityPersister() {
|
||||
return getCapability( EntityPersister.class );
|
||||
}
|
||||
|
||||
default EntityIdentifierMapping getIdentifierMapping() {
|
||||
return getCapability( EntityIdentifierMapping.class );
|
||||
}
|
||||
|
||||
default EntityVersionMapping getVersionMapping() {
|
||||
return getCapability( EntityVersionMapping.class );
|
||||
}
|
||||
|
||||
default EntityDiscriminatorMapping getDiscriminatorMapping() {
|
||||
return getCapability( EntityDiscriminatorMapping.class );
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
interface EmbeddableMapping extends ModelPart, ModelPartContainer {
|
||||
...
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
== Relationship with legacy "persister walking" SPI
|
||||
|
||||
`org.hibernate.metamodel.model.mapping` contract corollaries in `org.hibernate.persister.walking`:
|
||||
|
||||
EntityMapping::EntityDefinition
|
||||
EmbeddableMapping::CompositionDefinition
|
||||
AttributeMapping::AttributeDefinition
|
||||
EntityIdentifierMapping::EntityIdentifierDefinition
|
||||
|
||||
|
||||
== AllowableParameterType
|
||||
|
||||
`AllowableParameterType` is a contract that defines types that are valid for parameter binding in terms of an SQM query.
|
||||
|
||||
AT some point this needs to be "resolved" to a ValueMapping/Type/Bindable when generating the SQL AST and executing.
|
||||
|
||||
One option is to have the `AllowableParameterType` be resolved first to a `SqmExpressable`
|
||||
`SqmExpressableAllowableParameterType#resolveSqmExpressable`
|
|
@ -9,7 +9,7 @@ package org.hibernate.loader.spi;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.sql.ast.JoinType;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||
|
|
|
@ -117,7 +117,8 @@ public class AttributeFactory {
|
|||
attributeMetadata.getMember(),
|
||||
false,
|
||||
false,
|
||||
property.isOptional()
|
||||
property.isOptional(),
|
||||
metadataContext
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -159,7 +160,8 @@ public class AttributeFactory {
|
|||
property.getName(),
|
||||
determineSimpleType( attributeMetadata.getValueContext() ),
|
||||
attributeMetadata.getMember(),
|
||||
attributeMetadata.getAttributeClassification()
|
||||
attributeMetadata.getAttributeClassification(),
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -189,7 +191,8 @@ public class AttributeFactory {
|
|||
property.getName(),
|
||||
attributeMetadata.getAttributeClassification(),
|
||||
determineSimpleType( attributeMetadata.getValueContext() ),
|
||||
attributeMetadata.getMember()
|
||||
attributeMetadata.getMember(),
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.hibernate.internal.EntityManagerMessageLogger;
|
|||
import org.hibernate.internal.HEMLogging;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.internal.util.collections.Stack;
|
||||
import org.hibernate.internal.util.collections.StandardStack;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
|
@ -96,6 +98,8 @@ public class MetadataContext {
|
|||
private List<PersistentClass> stackOfPersistentClassesBeingProcessed = new ArrayList<>();
|
||||
private DomainMetamodel metamodel;
|
||||
|
||||
private Stack<String> containerRoleStack = new StandardStack<>();
|
||||
|
||||
public MetadataContext(
|
||||
JpaMetamodel jpaMetamodel,
|
||||
RuntimeModelCreationContext runtimeModelCreationContext,
|
||||
|
@ -129,6 +133,10 @@ public class MetadataContext {
|
|||
return metamodel;
|
||||
}
|
||||
|
||||
public Stack<String> getContainerRoleStack() {
|
||||
return containerRoleStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@linkplain Class java type} to {@link EntityTypeImpl} map.
|
||||
*
|
||||
|
@ -249,29 +257,39 @@ public class MetadataContext {
|
|||
try {
|
||||
final EntityDomainType<?> jpaMapping = entityTypesByPersistentClass.get( safeMapping );
|
||||
|
||||
applyIdMetadata( safeMapping, jpaMapping );
|
||||
applyVersionAttribute( safeMapping, jpaMapping );
|
||||
containerRoleStack.push( jpaMapping.getMappingRole() );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( property.getValue() == safeMapping.getIdentifierMapper() ) {
|
||||
// property represents special handling for id-class mappings but we have already
|
||||
// accounted for the embedded property mappings in #applyIdMetadata &&
|
||||
// #buildIdClassAttributes
|
||||
continue;
|
||||
}
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( jpaMapping, property );
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().addAttribute( attribute );
|
||||
try {
|
||||
applyIdMetadata( safeMapping, jpaMapping );
|
||||
applyVersionAttribute( safeMapping, jpaMapping );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( property.getValue() == safeMapping.getIdentifierMapper() ) {
|
||||
// property represents special handling for id-class mappings but we have already
|
||||
// accounted for the embedded property mappings in #applyIdMetadata &&
|
||||
// #buildIdClassAttributes
|
||||
continue;
|
||||
}
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute(
|
||||
jpaMapping,
|
||||
property
|
||||
);
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().finishUp();
|
||||
}
|
||||
finally {
|
||||
containerRoleStack.pop();
|
||||
}
|
||||
|
||||
( ( AttributeContainer) jpaMapping ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( jpaMapping );
|
||||
|
@ -291,22 +309,31 @@ public class MetadataContext {
|
|||
try {
|
||||
final MappedSuperclassDomainType<?> jpaType = mappedSuperclassByMappedSuperclassMapping.get( safeMapping );
|
||||
|
||||
applyIdMetadata( safeMapping, jpaType );
|
||||
applyVersionAttribute( safeMapping, jpaType );
|
||||
containerRoleStack.push( jpaType.getTypeName() );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( jpaType, property );
|
||||
if ( attribute != null ) {
|
||||
( ( AttributeContainer) jpaType ).getInFlightAccess().addAttribute( attribute );
|
||||
try {
|
||||
|
||||
applyIdMetadata( safeMapping, jpaType );
|
||||
applyVersionAttribute( safeMapping, jpaType );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( jpaType, property );
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaType ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
( (AttributeContainer) jpaType ).getInFlightAccess().finishUp();
|
||||
}
|
||||
finally {
|
||||
containerRoleStack.pop();
|
||||
}
|
||||
( ( AttributeContainer) jpaType ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( jpaType );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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.metamodel.model.mapping.spi;
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.metamodel.mapping;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Something that can be expressable at the mapping model level.
|
||||
*
|
||||
* Generally this is used generation of SQL AST
|
||||
*
|
||||
* todo (6.0) : Better name? This one's a bit verbose. See description for clues
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public interface MappingModelExpressable<T> {
|
||||
JavaTypeDescriptor<T> getExpressableJavaTypeDescriptor();
|
||||
|
||||
// todo (6.0) : others?
|
||||
// Probably `org.hibernate.metamodel.mapping.Bindable` should be consumed here. Or at least exposed from here
|
||||
//
|
||||
// todo (6.0) : IMO `Bindable` should be consumed here and `Bindable` go away
|
||||
|
||||
void visitJdbcTypes(Consumer<SqlExpressableType> action, TypeConfiguration typeConfiguration);
|
||||
|
||||
default Bindable getBindable() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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.metamodel.mapping;
|
||||
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* Parts of the ModelPart hierarchy that are type descriptors, as opposed to attributes e.g.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface MappingType extends ModelPart {
|
||||
JavaTypeDescriptor getMappedJavaTypeDescriptor();
|
||||
}
|
|
@ -4,13 +4,14 @@
|
|||
* 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.metamodel.model.mapping.spi;
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Describes a mapping of related to any part of the app's domain model - e.g.
|
||||
|
@ -21,13 +22,14 @@ import org.hibernate.sql.results.spi.DomainResultProducer;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ModelPart extends ValueMapping {
|
||||
public interface ModelPart extends MappingModelExpressable {
|
||||
|
||||
/**
|
||||
* Create a DomainResult for a specific reference to this ModelPart.
|
||||
*/
|
||||
default <T> DomainResult<T> createDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
|
@ -38,6 +40,7 @@ public interface ModelPart extends ValueMapping {
|
|||
*/
|
||||
default void applySqlSelections(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* 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.metamodel.model.mapping.spi;
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -15,18 +15,18 @@ import org.hibernate.NotYetImplementedFor6Exception;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ValueMappingContainer extends ModelPart {
|
||||
public interface ModelPartContainer extends ModelPart {
|
||||
/**
|
||||
* Find a sub-ValueMapping by name
|
||||
*/
|
||||
default ValueMapping findValueMapping(String name){
|
||||
default ModelPart findSubPart(String name){
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit all of this container's sub-ValueMappings
|
||||
*/
|
||||
default void visitValueMappings(Consumer<ValueMapping> consumer){
|
||||
default void visitSubParts(Consumer<ModelPart> consumer){
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* 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.metamodel.model.mapping.spi;
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* Unifying contract for things that are capable of being an expression in
|
|
@ -4,7 +4,7 @@
|
|||
* 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.metamodel.model.mapping.spi;
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
|
@ -4,13 +4,14 @@
|
|||
* 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.metamodel.model.mapping.spi;
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Describes a mapping related to any part of the app's domain model - e.g.
|
||||
|
@ -22,23 +23,7 @@ import org.hibernate.type.Type;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ValueMapping extends ValueMappingExpressable {
|
||||
|
||||
/**
|
||||
* Get the Type associated with this mapping
|
||||
*/
|
||||
default Type getValueType() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
default Bindable getBindable() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
default ValueMapping getExpressableValueMapping() {
|
||||
return this;
|
||||
}
|
||||
public interface ValueMapping extends MappingModelExpressable {
|
||||
|
||||
/**
|
||||
* Treat operation. Asks the ValueMapping to treat itself as the
|
|
@ -9,7 +9,6 @@
|
|||
* Hibernate's run-time mapping model
|
||||
*
|
||||
* @implNote At the moment, most of this mapping model is defined in the
|
||||
* {@link org.hibernate.persister} package. The intention is to move
|
||||
* all run-time mapping model contracts here.
|
||||
* {@link org.hibernate.persister} package.
|
||||
*/
|
||||
package org.hibernate.metamodel.model.mapping;
|
||||
package org.hibernate.metamodel.mapping;
|
|
@ -6,14 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.model.convert.spi;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
|
||||
/**
|
||||
* Describes a part of the domain model to which a value converter can be applied
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ConvertibleValueMapping<O> extends ValueMapping {
|
||||
public interface ConvertibleValueMapping<O> extends ModelPart {
|
||||
/**
|
||||
* Get the value converter associated with this value mapping. May
|
||||
* return {@code null}
|
||||
|
|
|
@ -15,6 +15,7 @@ import javax.persistence.metamodel.SingularAttribute;
|
|||
|
||||
import org.hibernate.metamodel.model.domain.internal.AttributeContainer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Defines commonality for the JPA {@link IdentifiableType} types. JPA defines
|
||||
|
@ -268,6 +269,18 @@ public abstract class AbstractIdentifiableType<J>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJdbcTypes(Consumer action, TypeConfiguration typeConfiguration) {
|
||||
id.visitJdbcTypes( action, typeConfiguration );
|
||||
|
||||
if ( versionAttribute != null ) {
|
||||
versionAttribute.visitJdbcTypes( action, typeConfiguration );
|
||||
}
|
||||
|
||||
visitAttributes(
|
||||
attribute -> attribute.visitJdbcTypes( action, typeConfiguration )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* For used to retrieve the declared version when populating the static metamodel.
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.metamodel.model.domain;
|
|||
import javax.persistence.metamodel.Attribute;
|
||||
|
||||
import org.hibernate.metamodel.AttributeClassification;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +17,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface PersistentAttribute<D,J> extends Attribute<D,J> {
|
||||
public interface PersistentAttribute<D,J> extends Attribute<D,J>, ModelPart {
|
||||
@Override
|
||||
ManagedDomainType<D> getDeclaringType();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.metamodel.model.domain;
|
|||
|
||||
import javax.persistence.metamodel.SingularAttribute;
|
||||
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.query.sqm.SqmJoinable;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
|
||||
|
@ -17,7 +18,7 @@ import org.hibernate.query.sqm.SqmPathSource;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SingularPersistentAttribute<D,J>
|
||||
extends SingularAttribute<D,J>, PersistentAttribute<D,J>, SqmPathSource<J>, SqmJoinable {
|
||||
extends SingularAttribute<D,J>, PersistentAttribute<D,J>, ModelPart, SqmPathSource<J>, SqmJoinable {
|
||||
@Override
|
||||
SimpleDomainType<J> getType();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import javax.persistence.metamodel.Attribute;
|
|||
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.metamodel.AttributeClassification;
|
||||
import org.hibernate.metamodel.internal.MetadataContext;
|
||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||
import org.hibernate.metamodel.model.domain.PersistentAttribute;
|
||||
import org.hibernate.metamodel.model.domain.SimpleDomainType;
|
||||
|
@ -39,6 +40,7 @@ public abstract class AbstractAttribute<D,J,B> implements PersistentAttribute<D,
|
|||
private final SimpleDomainType<B> valueType;
|
||||
private transient Member member;
|
||||
|
||||
private final String mappingRole;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected AbstractAttribute(
|
||||
|
@ -47,13 +49,16 @@ public abstract class AbstractAttribute<D,J,B> implements PersistentAttribute<D,
|
|||
JavaTypeDescriptor<J> attributeType,
|
||||
AttributeClassification attributeClassification,
|
||||
SimpleDomainType<B> valueType,
|
||||
Member member) {
|
||||
Member member,
|
||||
MetadataContext metadataContext) {
|
||||
this.declaringType = declaringType;
|
||||
this.name = name;
|
||||
this.attributeType = attributeType;
|
||||
this.attributeClassification = attributeClassification;
|
||||
this.valueType = valueType;
|
||||
this.member = member;
|
||||
|
||||
this.mappingRole = metadataContext.getContainerRoleStack().getCurrent() + '.' + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,6 +66,10 @@ public abstract class AbstractAttribute<D,J,B> implements PersistentAttribute<D,
|
|||
return name;
|
||||
}
|
||||
|
||||
public String getMappingRole() {
|
||||
return mappingRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<J> getJavaType() {
|
||||
return attributeType.getJavaType();
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.io.Serializable;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
import org.hibernate.metamodel.internal.MetadataContext;
|
||||
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
|
||||
import org.hibernate.metamodel.model.domain.SimpleDomainType;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
|
@ -35,14 +36,17 @@ public abstract class AbstractPluralAttribute<D,C,E>
|
|||
private final SqmPathSource<E> elementPathSource;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected AbstractPluralAttribute(PluralAttributeBuilder<D,C,E,?> builder) {
|
||||
protected AbstractPluralAttribute(
|
||||
PluralAttributeBuilder<D,C,E,?> builder,
|
||||
MetadataContext metadataContext) {
|
||||
super(
|
||||
builder.getDeclaringType(),
|
||||
builder.getProperty().getName(),
|
||||
builder.getCollectionJavaTypeDescriptor(),
|
||||
builder.getAttributeClassification(),
|
||||
builder.getValueType(),
|
||||
builder.getMember()
|
||||
builder.getMember(),
|
||||
metadataContext
|
||||
);
|
||||
|
||||
this.classification = builder.getCollectionClassification();
|
||||
|
@ -59,6 +63,11 @@ public abstract class AbstractPluralAttribute<D,C,E>
|
|||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappingRole() {
|
||||
return super.getMappingRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionClassification getCollectionClassification() {
|
||||
return classification;
|
||||
|
|
|
@ -15,14 +15,17 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|||
*/
|
||||
public abstract class AbstractSqmPathSource<J> implements SqmPathSource<J> {
|
||||
private final String localPathName;
|
||||
private final String roleName;
|
||||
private final DomainType<J> domainType;
|
||||
private final BindableType jpaBindableType;
|
||||
|
||||
public AbstractSqmPathSource(
|
||||
String localPathName,
|
||||
String roleName,
|
||||
DomainType<J> domainType,
|
||||
BindableType jpaBindableType) {
|
||||
this.localPathName = localPathName;
|
||||
this.roleName = roleName;
|
||||
this.domainType = domainType;
|
||||
this.jpaBindableType = jpaBindableType;
|
||||
}
|
||||
|
@ -32,6 +35,11 @@ public abstract class AbstractSqmPathSource<J> implements SqmPathSource<J> {
|
|||
return localPathName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappingRole() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainType<?> getSqmPathType() {
|
||||
return domainType;
|
||||
|
|
|
@ -24,6 +24,11 @@ public class AnyMappingSqmPathSource<J> extends AbstractSqmPathSource<J> {
|
|||
super( localPathName, domainType, jpaBindableType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappingRole() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnyMappingDomainType<J> getSqmPathType() {
|
||||
//noinspection unchecked
|
||||
|
|
|
@ -25,9 +25,10 @@ public class BasicSqmPathSource<J>
|
|||
@SuppressWarnings("WeakerAccess")
|
||||
public BasicSqmPathSource(
|
||||
String localPathName,
|
||||
String roleName,
|
||||
BasicDomainType<J> domainType,
|
||||
BindableType jpaBindableType) {
|
||||
super( localPathName, domainType, jpaBindableType );
|
||||
super( localPathName, roleName, domainType, jpaBindableType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.metamodel.model.domain.internal;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -43,6 +44,8 @@ import org.hibernate.internal.util.collections.ArrayHelper;
|
|||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||
|
@ -55,7 +58,10 @@ import org.hibernate.persister.collection.CollectionPersister;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Queryable;
|
||||
import org.hibernate.persister.spi.PersisterFactory;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -97,6 +103,7 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
// DomainMetamodel
|
||||
|
||||
private final Set<EntityNameResolver> entityNameResolvers = new HashSet<>();
|
||||
private final Map<String, ModelPart> modelPartRoleMap = new HashMap<>();
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -219,6 +226,7 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
modelCreationContext
|
||||
);
|
||||
entityPersisterMap.put( model.getEntityName(), cp );
|
||||
modelPartRoleMap.put( model.getEntityName(), cp );
|
||||
|
||||
if ( cp.getConcreteProxyClass() != null
|
||||
&& cp.getConcreteProxyClass().isInterface()
|
||||
|
@ -685,4 +693,26 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
|
||||
return results.toArray( new String[results.size()] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingModelExpressable resolveMappingExpressable(SqmExpressable<?> sqmExpressable) {
|
||||
|
||||
if ( sqmExpressable instanceof BasicType<?> ) {
|
||||
return (BasicType) sqmExpressable;
|
||||
}
|
||||
else if ( sqmExpressable instanceof SqmPathSource ) {
|
||||
final SqmPathSource pathSource = (SqmPathSource) sqmExpressable;
|
||||
final String role = pathSource.getMappingRole();
|
||||
|
||||
return modelPartRoleMap.get( role );
|
||||
|
||||
/*
|
||||
"org...Person" -> EntityPersister(Person)
|
||||
"org...Person.name" -> AttributeDescriptor(..)
|
||||
"org...Person.name.first" -> AttributeDescriptor(..)
|
||||
*/
|
||||
}
|
||||
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,10 @@ import org.hibernate.query.sqm.tree.domain.SqmPath;
|
|||
public class EmbeddedSqmPathSource<J> extends AbstractSqmPathSource<J> implements AllowableParameterType<J> {
|
||||
public EmbeddedSqmPathSource(
|
||||
String localPathName,
|
||||
String roleName,
|
||||
EmbeddableDomainType<J> domainType,
|
||||
BindableType jpaBindableType) {
|
||||
super( localPathName, domainType, jpaBindableType );
|
||||
super( localPathName, roleName, domainType, jpaBindableType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,9 +21,10 @@ import org.hibernate.query.sqm.tree.domain.SqmPath;
|
|||
public class EntitySqmPathSource<J> extends AbstractSqmPathSource<J> {
|
||||
public EntitySqmPathSource(
|
||||
String localPathName,
|
||||
String roleName,
|
||||
EntityDomainType<J> domainType,
|
||||
BindableType jpaBindableType) {
|
||||
super( localPathName, domainType, jpaBindableType );
|
||||
super( localPathName, roleName, domainType, jpaBindableType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,6 +48,7 @@ public class EntityTypeImpl<J>
|
|||
persistentClass.isVersioned(),
|
||||
jpaMetamodel
|
||||
);
|
||||
|
||||
this.jpaEntityName = persistentClass.getJpaEntityName();
|
||||
}
|
||||
|
||||
|
@ -56,6 +57,11 @@ public class EntityTypeImpl<J>
|
|||
return jpaEntityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappingRole() {
|
||||
return getHibernateEntityName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHibernateEntityName() {
|
||||
return super.getTypeName();
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import org.hibernate.graph.spi.GraphHelper;
|
||||
import org.hibernate.metamodel.AttributeClassification;
|
||||
import org.hibernate.metamodel.internal.MetadataContext;
|
||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||
import org.hibernate.metamodel.model.domain.SimpleDomainType;
|
||||
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
|
||||
|
@ -48,8 +49,17 @@ public class SingularAttributeImpl<D,J>
|
|||
Member member,
|
||||
boolean isIdentifier,
|
||||
boolean isVersion,
|
||||
boolean isOptional) {
|
||||
super( declaringType, name, attributeType.getExpressableJavaTypeDescriptor(), attributeClassification, attributeType, member );
|
||||
boolean isOptional,
|
||||
MetadataContext metadataContext) {
|
||||
super(
|
||||
declaringType,
|
||||
name,
|
||||
attributeType.getExpressableJavaTypeDescriptor(),
|
||||
attributeClassification,
|
||||
attributeType,
|
||||
member,
|
||||
metadataContext
|
||||
);
|
||||
this.isIdentifier = isIdentifier;
|
||||
this.isVersion = isVersion;
|
||||
this.isOptional = isOptional;
|
||||
|
@ -67,6 +77,15 @@ public class SingularAttributeImpl<D,J>
|
|||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappingRole() {
|
||||
return super.getMappingRole();
|
||||
}
|
||||
|
||||
public JavaTypeDescriptor<J> getExpressableJavaTypeDescriptor() {
|
||||
return sqmPathSource.getExpressableJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleDomainType<J> getSqmPathType() {
|
||||
//noinspection unchecked
|
||||
|
@ -88,10 +107,6 @@ public class SingularAttributeImpl<D,J>
|
|||
return getSqmPathType();
|
||||
}
|
||||
|
||||
public JavaTypeDescriptor<J> getExpressableJavaTypeDescriptor() {
|
||||
return sqmPathSource.getExpressableJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<J> getBindableJavaType() {
|
||||
return getExpressableJavaTypeDescriptor().getJavaType();
|
||||
|
@ -130,7 +145,8 @@ public class SingularAttributeImpl<D,J>
|
|||
String name,
|
||||
SimpleDomainType<J> attributeType,
|
||||
Member member,
|
||||
AttributeClassification attributeClassification) {
|
||||
AttributeClassification attributeClassification,
|
||||
MetadataContext metadataContext) {
|
||||
super(
|
||||
declaringType,
|
||||
name,
|
||||
|
@ -139,7 +155,8 @@ public class SingularAttributeImpl<D,J>
|
|||
member,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
false,
|
||||
metadataContext
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +171,8 @@ public class SingularAttributeImpl<D,J>
|
|||
String name,
|
||||
AttributeClassification attributeClassification,
|
||||
SimpleDomainType<Y> attributeType,
|
||||
Member member) {
|
||||
Member member,
|
||||
MetadataContext metadataContext) {
|
||||
super(
|
||||
declaringType,
|
||||
name,
|
||||
|
@ -163,7 +181,8 @@ public class SingularAttributeImpl<D,J>
|
|||
member,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
metadataContext
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,17 @@ import java.util.function.Consumer;
|
|||
import org.hibernate.Incubating;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.graph.RootGraph;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.metamodel.model.domain.BasicDomainType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -52,9 +54,7 @@ public interface DomainMetamodel {
|
|||
* @param sqmExpressable
|
||||
* @return
|
||||
*/
|
||||
default ValueMapping resolveValueMapping(SqmExpressable<?> sqmExpressable) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
MappingModelExpressable resolveMappingExpressable(SqmExpressable<?> sqmExpressable);
|
||||
|
||||
/**
|
||||
* Given a Java type, determine the corresponding AllowableParameterType to
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.hibernate.cache.spi.entry.CacheEntryStructure;
|
|||
import org.hibernate.cache.spi.entry.StructuredCollectionCacheEntry;
|
||||
import org.hibernate.cache.spi.entry.StructuredMapCacheEntry;
|
||||
import org.hibernate.cache.spi.entry.UnstructuredCacheEntry;
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
|
||||
|
@ -66,10 +65,10 @@ import org.hibernate.mapping.List;
|
|||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.metadata.CollectionMetadata;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Loadable;
|
||||
import org.hibernate.persister.entity.PropertyMapping;
|
||||
import org.hibernate.persister.entity.Queryable;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
|
@ -95,6 +94,8 @@ import org.hibernate.type.CollectionType;
|
|||
import org.hibernate.type.CompositeType;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -2179,6 +2180,16 @@ public abstract class AbstractCollectionPersister
|
|||
throw new IllegalStateException( "Cannot treat collection index type as composite" );
|
||||
}
|
||||
return new CompositeCollectionElementDefinition() {
|
||||
@Override
|
||||
public JavaTypeDescriptor getExpressableJavaTypeDescriptor() {
|
||||
return ( (EmbeddableDomainType) getType() ).getExpressableJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJdbcTypes(Consumer action, TypeConfiguration typeConfiguration) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "index";
|
||||
|
@ -2262,13 +2273,23 @@ public abstract class AbstractCollectionPersister
|
|||
|
||||
return new CompositeCollectionElementDefinition() {
|
||||
@Override
|
||||
public void visitValueMappings(Consumer consumer) {
|
||||
public JavaTypeDescriptor getExpressableJavaTypeDescriptor() {
|
||||
return ( (EmbeddableDomainType) getType() ).getExpressableJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJdbcTypes(Consumer action, TypeConfiguration typeConfiguration) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSubParts(Consumer<ModelPart> consumer) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping findValueMapping(String name) {
|
||||
public ModelPart findSubPart(String name) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.hibernate.JDBCException;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
|
@ -122,8 +121,8 @@ import org.hibernate.mapping.Selectable;
|
|||
import org.hibernate.mapping.Subclass;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.metadata.ClassMetadata;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.persister.walking.internal.EntityIdentifierDefinitionHelper;
|
||||
|
@ -143,14 +142,11 @@ import org.hibernate.sql.SelectFragment;
|
|||
import org.hibernate.sql.SimpleSelect;
|
||||
import org.hibernate.sql.Template;
|
||||
import org.hibernate.sql.Update;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.from.StandardTableGroup;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||
|
@ -1195,7 +1191,7 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping findValueMapping(String name) {
|
||||
public ModelPart findSubPart(String name) {
|
||||
for ( AttributeDefinition attributeDefinition : attributeDefinitions ) {
|
||||
if ( attributeDefinition.getName().equals( name ) ) {
|
||||
return attributeDefinition;
|
||||
|
@ -1206,7 +1202,7 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
|
||||
@Override
|
||||
public void visitValueMappings(Consumer<ValueMapping> consumer) {
|
||||
public void visitSubParts(Consumer<ModelPart> consumer) {
|
||||
consumer.accept( entityIdentifierDefinition );
|
||||
|
||||
for ( AttributeDefinition attributeDefinition : attributeDefinitions ) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.persister.walking.internal;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
|
@ -35,6 +36,8 @@ import org.hibernate.type.AnyType;
|
|||
import org.hibernate.type.AssociationType;
|
||||
import org.hibernate.type.CompositeType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* A helper for getting attributes from a composition that is known
|
||||
|
@ -137,6 +140,18 @@ public final class CompositionSingularSubAttributesHelper {
|
|||
if ( type.isAssociationType() ) {
|
||||
final AssociationType aType = (AssociationType) type;
|
||||
return new AssociationAttributeDefinition() {
|
||||
@Override
|
||||
public JavaTypeDescriptor getExpressableJavaTypeDescriptor() {
|
||||
return ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJdbcTypes(
|
||||
Consumer action,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssociationKey getAssociationKey() {
|
||||
return new AssociationKey( lhsTableName, subAttributeLhsColumns );
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.persister.walking.spi;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Descriptor for
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AttributeDefinition extends ValueMapping {
|
||||
public interface AttributeDefinition extends ModelPart {
|
||||
AttributeSource getSource();
|
||||
String getName();
|
||||
Type getType();
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.persister.walking.spi;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMappingContainer;
|
||||
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AttributeSource extends ValueMappingContainer {
|
||||
public interface AttributeSource extends ModelPartContainer {
|
||||
Iterable<AttributeDefinition> getAttributes();
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.persister.walking.spi;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
|
||||
/**
|
||||
* Describes aspects of the identifier for an entity
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityIdentifierDefinition extends ValueMapping {
|
||||
public interface EntityIdentifierDefinition extends ModelPart {
|
||||
/**
|
||||
* Is the entity identifier encapsulated? Meaning, is it represented by a single attribute?
|
||||
*
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.procedure.internal;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
@ -16,7 +14,6 @@ import java.util.Date;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.LockModeType;
|
||||
import javax.persistence.NoResultException;
|
||||
|
@ -62,8 +59,7 @@ import org.hibernate.result.UpdateCountOutput;
|
|||
import org.hibernate.result.spi.ResultContext;
|
||||
import org.hibernate.sql.exec.spi.DomainParameterBindingContext;
|
||||
import org.hibernate.sql.results.NoMoreOutputsException;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
|
|
@ -8,10 +8,9 @@ package org.hibernate.procedure.internal;
|
|||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.sql.results.internal.ScalarDomainResultImpl;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
|
|
@ -11,13 +11,10 @@ import java.util.function.Consumer;
|
|||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.metamodel.spi.DomainMetamodel;
|
||||
import org.hibernate.query.named.NamedQueryRepository;
|
||||
import org.hibernate.query.named.NamedResultSetMappingMemento;
|
||||
import org.hibernate.query.spi.ResultSetMapping;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
|||
import org.hibernate.query.sqm.tree.expression.SqmFieldLiteral;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
|
@ -240,8 +239,4 @@ public class FullyQualifiedReflectivePathTerminal
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer getDomainResultProducer() {
|
||||
throw new UnsupportedOperationException( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.query.spi;
|
|||
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.query.named.NamedResultSetMappingMemento;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Describes a ResultSet mapping applied to either a {@link org.hibernate.query.NativeQuery}
|
||||
|
|
|
@ -23,6 +23,12 @@ import org.hibernate.query.sqm.tree.domain.SqmPath;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmPathSource<J> extends SqmExpressable<J>, Bindable<J> {
|
||||
/**
|
||||
* A sort-of unique key for a part of the model as a compound (dot-separated) name.
|
||||
* Will end with {@link #getPathName}
|
||||
*/
|
||||
String getMappingRole();
|
||||
|
||||
/**
|
||||
* The name of this thing. Mainly used in logging and when creating a
|
||||
* {@link org.hibernate.query.NavigablePath}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.hibernate.query.sqm.SemanticQueryWalker;
|
|||
import org.hibernate.query.sqm.produce.function.SqmFunctionTemplate;
|
||||
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Specialized CASE statement for resolving the first non-null value in a list of values
|
||||
|
@ -103,8 +103,4 @@ public class SqmCoalesce<T> extends AbstractSqmExpression<T> implements JpaCoale
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.query.sqm.function;
|
|||
import org.hibernate.query.criteria.JpaFunction;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Contract for functions impls that would like to control the
|
||||
|
@ -37,8 +37,4 @@ public interface SqmFunction<T> extends SqmExpression<T>, JpaFunction<T>, Domain
|
|||
return walker.visitFunction( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
default DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.query.sqm.function;
|
|||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
|
@ -25,8 +24,4 @@ public class SqmStar extends AbstractSqmExpression<Object> {
|
|||
return walker.visitStar(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<Object> getDomainResultProducer() {
|
||||
throw new UnsupportedOperationException( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.hibernate.NotYetImplementedFor6Exception;
|
|||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.internal.util.collections.Stack;
|
||||
import org.hibernate.internal.util.collections.StandardStack;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.BinaryArithmeticOperator;
|
||||
import org.hibernate.query.UnaryArithmeticOperator;
|
||||
|
@ -37,16 +37,21 @@ import org.hibernate.query.sqm.internal.DomainParameterXref;
|
|||
import org.hibernate.query.sqm.spi.BaseSemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.spi.JdbcParameterBySqmParameterAccess;
|
||||
import org.hibernate.query.sqm.sql.internal.SqlAstQuerySpecProcessingStateImpl;
|
||||
import org.hibernate.query.sqm.sql.internal.SqmExpressionInterpretation;
|
||||
import org.hibernate.query.sqm.sql.internal.SqmPathInterpretation;
|
||||
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmEntityValuedSimplePath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmBinaryArithmetic;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmCaseSearched;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmCaseSimple;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmCriteriaParameter;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmEnumLiteral;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmFieldLiteral;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmLiteral;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmNamedParameter;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||
|
@ -55,6 +60,7 @@ import org.hibernate.query.sqm.tree.expression.SqmUnaryOperation;
|
|||
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmCrossJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmEntityJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmFrom;
|
||||
import org.hibernate.query.sqm.tree.from.SqmFromClause;
|
||||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
import org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement;
|
||||
|
@ -78,7 +84,6 @@ import org.hibernate.query.sqm.tree.select.SqmSubQuery;
|
|||
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.JoinType;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
|
@ -86,6 +91,7 @@ import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression;
|
|||
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
|
||||
import org.hibernate.sql.ast.tree.expression.CaseSimpleExpression;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
|
||||
import org.hibernate.sql.ast.tree.expression.SqlTuple;
|
||||
import org.hibernate.sql.ast.tree.expression.UnaryOperation;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
@ -265,7 +271,6 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
this,
|
||||
currentClauseStack::getCurrent,
|
||||
() -> (expression) -> {},
|
||||
() -> sqlQuerySpec.getSelectClause()::addSelection,
|
||||
() -> sqlQuerySpec.getSelectClause()::addSqlSelection
|
||||
)
|
||||
);
|
||||
|
@ -384,18 +389,10 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
try {
|
||||
sqmFromClause.visitRoots(
|
||||
sqmRoot -> {
|
||||
final EntityPersister entityDescriptor = resolveEntityPersister( sqmRoot.getReferencedPathSource() );
|
||||
|
||||
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
||||
sqmRoot.getNavigablePath(),
|
||||
sqmRoot.getExplicitAlias(),
|
||||
null,
|
||||
determineLockMode( sqmRoot.getExplicitAlias() ),
|
||||
sqlAliasBaseManager,
|
||||
creationContext
|
||||
);
|
||||
final TableGroup rootTableGroup = visitRootPath( sqmRoot );
|
||||
|
||||
currentQuerySpec().getFromClause().addRoot( rootTableGroup );
|
||||
getFromClauseIndex().register( sqmRoot, rootTableGroup );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -407,18 +404,16 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TableGroup visitRootPath(SqmRoot<?> sqmRoot) {
|
||||
log.tracef( "Starting resolution of SqmRoot [%s] to TableGroup", sqmRoot );
|
||||
|
||||
if ( fromClauseIndex.isResolved( sqmRoot ) ) {
|
||||
final TableGroup resolvedTableGroup = fromClauseIndex.findTableGroup( sqmRoot.getNavigablePath() );
|
||||
final TableGroup resolvedTableGroup = fromClauseIndex.findTableGroup( sqmRoot.getNavigablePath() );
|
||||
if ( resolvedTableGroup != null ) {
|
||||
log.tracef( "SqmRoot [%s] resolved to existing TableGroup [%s]", sqmRoot, resolvedTableGroup );
|
||||
return resolvedTableGroup;
|
||||
}
|
||||
|
||||
|
||||
final EntityPersister entityDescriptor = resolveEntityPersister( sqmRoot.getReferencedPathSource() );
|
||||
|
||||
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
||||
|
@ -435,14 +430,8 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
|
||||
log.tracef( "Resolved SqmRoot [%s] to new TableGroup [%s]", sqmRoot, tableGroup );
|
||||
|
||||
sqmRoot.visitSqmJoins(
|
||||
sqmJoin -> {
|
||||
final TableGroupJoin tableGroupJoin = (TableGroupJoin) sqmJoin.accept( this );
|
||||
if ( tableGroupJoin != null ) {
|
||||
tableGroup.addTableGroupJoin( tableGroupJoin );
|
||||
}
|
||||
}
|
||||
);
|
||||
visitExplicitJoins( sqmRoot, tableGroup );
|
||||
visitImplicitJoins( sqmRoot, tableGroup );
|
||||
|
||||
return tableGroup;
|
||||
}
|
||||
|
@ -451,6 +440,30 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
return creationContext.getDomainModel().getEntityDescriptor( entityDomainType.getHibernateEntityName() );
|
||||
}
|
||||
|
||||
private void visitExplicitJoins(SqmFrom<?,?> sqmFrom, TableGroup tableGroup) {
|
||||
log.tracef( "Visiting explicit joins for `%s`", sqmFrom.getNavigablePath() );
|
||||
|
||||
sqmFrom.visitSqmJoins(
|
||||
sqmJoin -> {
|
||||
final TableGroupJoin tableGroupJoin = (TableGroupJoin) sqmJoin.accept( this );
|
||||
if ( tableGroupJoin != null ) {
|
||||
tableGroup.addTableGroupJoin( tableGroupJoin );
|
||||
getFromClauseIndex().register( sqmFrom, tableGroup );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void visitImplicitJoins(SqmPath<?> sqmPath, TableGroup tableGroup) {
|
||||
log.tracef( "Visiting implicit joins for `%s`", sqmPath.getNavigablePath() );
|
||||
|
||||
sqmPath.visitImplicitJoinPaths(
|
||||
joinedPath -> {
|
||||
log.tracef( "Starting implicit join handling for `%s`", joinedPath.getNavigablePath() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableGroupJoin visitQualifiedAttributeJoin(SqmAttributeJoin<?, ?> sqmJoin) {
|
||||
final TableGroupJoin tableJoinJoin = fromClauseIndex.findTableGroupJoin( sqmJoin.getNavigablePath() );
|
||||
|
@ -554,23 +567,32 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object visitBasicValuedPath(SqmBasicValuedSimplePath path) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
public SqmPathInterpretation visitBasicValuedPath(SqmBasicValuedSimplePath sqmPath) {
|
||||
final SqmPath<?> lhs = sqmPath.getLhs();
|
||||
assert lhs != null;
|
||||
|
||||
return (SqmPathInterpretation) sqmPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitEmbeddableValuedPath(SqmEmbeddedValuedSimplePath path) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
public SqmPathInterpretation visitEmbeddableValuedPath(SqmEmbeddedValuedSimplePath sqmPath) {
|
||||
final SqmPath<?> lhs = sqmPath.getLhs();
|
||||
assert lhs != null;
|
||||
|
||||
return (SqmPathInterpretation) sqmPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitEntityValuedPath(SqmEntityValuedSimplePath path) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
public SqmPathInterpretation visitEntityValuedPath(SqmEntityValuedSimplePath sqmPath) {
|
||||
final SqmPath<?> lhs = sqmPath.getLhs();
|
||||
assert lhs != null;
|
||||
|
||||
return (SqmPathInterpretation) sqmPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitPluralValuedPath(SqmPluralValuedSimplePath path) {
|
||||
throw new NotYetImplementedFor6Exception();
|
||||
public SqmPathInterpretation visitPluralValuedPath(SqmPluralValuedSimplePath sqmPath) {
|
||||
return (SqmPathInterpretation) sqmPath;
|
||||
}
|
||||
|
||||
|
||||
|
@ -578,7 +600,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
// Expressions
|
||||
|
||||
@Override
|
||||
public Object visitLiteral(SqmLiteral literal) {
|
||||
public SqmExpressionInterpretation visitLiteral(SqmLiteral literal) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
// final ExpressableType<?> expressableType = determineExpressableType( literal );
|
||||
// if ( expressableType instanceof BasicValuedExpressableType<?> ) {
|
||||
|
@ -612,7 +634,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
|
||||
private Expression consumeSqmParameter(SqmParameter sqmParameter) {
|
||||
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
||||
final ValueMapping valueMapping = determineValueMapping( sqmParameter );
|
||||
final MappingModelExpressable valueMapping = determineValueMapping( sqmParameter );
|
||||
|
||||
resolveSqmParameter( sqmParameter, valueMapping, jdbcParametersForSqm::add );
|
||||
|
||||
|
@ -620,25 +642,25 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
jdbcParamsBySqmParam.put( sqmParameter, jdbcParametersForSqm );
|
||||
|
||||
if ( jdbcParametersForSqm.size() > 1 ) {
|
||||
return new SqlTuple( jdbcParametersForSqm, () -> valueMapping );
|
||||
return new SqlTuple( jdbcParametersForSqm, valueMapping );
|
||||
}
|
||||
else {
|
||||
return jdbcParametersForSqm.get( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
protected ValueMapping determineValueMapping(SqmExpression<?> sqmExpression) {
|
||||
protected MappingModelExpressable<?> determineValueMapping(SqmExpression<?> sqmExpression) {
|
||||
final SqmExpressable<?> nodeType = sqmExpression.getNodeType();
|
||||
|
||||
ValueMapping valueMapping = getCreationContext().getDomainModel().resolveValueMapping( nodeType );
|
||||
MappingModelExpressable valueMapping = getCreationContext().getDomainModel().resolveMappingExpressable( nodeType );
|
||||
// alternative
|
||||
// sqmExpression.resolveValueMapping( getCreationContext(), "inferableTypeAccessStack" );
|
||||
// sqmExpression.resolveMappingExpressable( getCreationContext(), "inferableTypeAccessStack" );
|
||||
|
||||
|
||||
if ( valueMapping == null ) {
|
||||
final Supplier<ValueMappingExpressable> currentExpressableSupplier = inferableTypeAccessStack.getCurrent();
|
||||
final Supplier<MappingModelExpressable> currentExpressableSupplier = inferableTypeAccessStack.getCurrent();
|
||||
if ( currentExpressableSupplier != null ) {
|
||||
valueMapping = currentExpressableSupplier.get().getExpressableValueMapping();
|
||||
valueMapping = currentExpressableSupplier.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,11 +672,11 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
}
|
||||
|
||||
|
||||
private final Stack<Supplier<ValueMappingExpressable>> inferableTypeAccessStack = new StandardStack<>(
|
||||
private final Stack<Supplier<MappingModelExpressable>> inferableTypeAccessStack = new StandardStack<>(
|
||||
() -> () -> null
|
||||
);
|
||||
|
||||
private void resolveSqmParameter(SqmParameter expression, ValueMapping valueMapping, Consumer<JdbcParameter> jdbcParameterConsumer) {
|
||||
private void resolveSqmParameter(SqmParameter expression, MappingModelExpressable valueMapping, Consumer<JdbcParameter> jdbcParameterConsumer) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
// if ( valueMapping == null ) {
|
||||
// final StandardJdbcParameterImpl jdbcParameter = new StandardJdbcParameterImpl(
|
||||
|
@ -1118,7 +1140,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
return new UnaryOperation(
|
||||
interpret( expression.getOperation() ),
|
||||
(Expression) expression.getOperand().accept( this ),
|
||||
() -> determineValueMapping( expression )
|
||||
determineValueMapping( expression )
|
||||
|
||||
);
|
||||
}
|
||||
|
@ -1148,7 +1170,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
return new BinaryArithmeticExpression(
|
||||
(Expression) expression.getLeftHandOperand().accept( this ), interpret( expression.getOperator() ),
|
||||
(Expression) expression.getRightHandOperand().accept( this ),
|
||||
() -> determineValueMapping( expression )
|
||||
determineValueMapping( expression )
|
||||
);
|
||||
}
|
||||
finally {
|
||||
|
@ -1198,7 +1220,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
@Override
|
||||
public CaseSimpleExpression visitSimpleCaseExpression(SqmCaseSimple<?,?> expression) {
|
||||
final CaseSimpleExpression result = new CaseSimpleExpression(
|
||||
() -> determineValueMapping( expression ),
|
||||
determineValueMapping( expression ),
|
||||
(Expression) expression.getFixture().accept( this )
|
||||
);
|
||||
|
||||
|
@ -1217,7 +1239,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
@Override
|
||||
public CaseSearchedExpression visitSearchedCaseExpression(SqmCaseSearched<?> expression) {
|
||||
final CaseSearchedExpression result = new CaseSearchedExpression(
|
||||
() -> determineValueMapping( expression )
|
||||
determineValueMapping( expression )
|
||||
);
|
||||
|
||||
for ( SqmCaseSearched.WhenFragment whenFragment : expression.getWhenFragments() ) {
|
||||
|
@ -1232,6 +1254,24 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitEnumLiteral(SqmEnumLiteral sqmEnumLiteral) {
|
||||
return new QueryLiteral(
|
||||
sqmEnumLiteral.getEnumValue(),
|
||||
determineValueMapping( sqmEnumLiteral ),
|
||||
getCurrentClauseStack().getCurrent()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitFieldLiteral(SqmFieldLiteral sqmFieldLiteral) {
|
||||
return new QueryLiteral(
|
||||
sqmFieldLiteral.getValue(),
|
||||
determineValueMapping( sqmFieldLiteral ),
|
||||
getCurrentClauseStack().getCurrent()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public Object visitPluralAttributeElementBinding(PluralAttributeElementBinding binding) {
|
||||
|
@ -1294,7 +1334,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
|
||||
@Override
|
||||
public ComparisonPredicate visitComparisonPredicate(SqmComparisonPredicate predicate) {
|
||||
inferableTypeAccessStack.push( () -> () -> determineValueMapping( predicate.getRightHandExpression() ) );
|
||||
inferableTypeAccessStack.push( () -> determineValueMapping( predicate.getRightHandExpression() ) );
|
||||
|
||||
final Expression lhs;
|
||||
try {
|
||||
|
@ -1304,7 +1344,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
inferableTypeAccessStack.pop();
|
||||
}
|
||||
|
||||
inferableTypeAccessStack.push( () -> () -> determineValueMapping( predicate.getLeftHandExpression() ) );
|
||||
inferableTypeAccessStack.push( () -> determineValueMapping( predicate.getLeftHandExpression() ) );
|
||||
|
||||
final Expression rhs;
|
||||
try {
|
||||
|
@ -1335,7 +1375,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
final Expression upperBound;
|
||||
|
||||
inferableTypeAccessStack.push(
|
||||
() -> () -> coalesce(
|
||||
() -> coalesce(
|
||||
determineValueMapping( predicate.getLowerBound() ),
|
||||
determineValueMapping( predicate.getUpperBound() )
|
||||
)
|
||||
|
@ -1349,7 +1389,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
}
|
||||
|
||||
inferableTypeAccessStack.push(
|
||||
() -> () -> coalesce(
|
||||
() -> coalesce(
|
||||
determineValueMapping( predicate.getExpression() ),
|
||||
determineValueMapping( predicate.getUpperBound() )
|
||||
)
|
||||
|
@ -1362,7 +1402,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
}
|
||||
|
||||
inferableTypeAccessStack.push(
|
||||
() -> () -> coalesce(
|
||||
() -> coalesce(
|
||||
determineValueMapping( predicate.getExpression() ),
|
||||
determineValueMapping( predicate.getLowerBound() )
|
||||
)
|
||||
|
@ -1423,7 +1463,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
);
|
||||
|
||||
inferableTypeAccessStack.push(
|
||||
() -> () -> determineValueMapping( predicate.getTestExpression() ) );
|
||||
() -> determineValueMapping( predicate.getTestExpression() ) );
|
||||
|
||||
try {
|
||||
boolean first = true;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.query.sqm.sql.internal;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.update.Assignment;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AssignableSqmPathInterpretation<T> extends SqmPathInterpretation<T> {
|
||||
// need to be able to collect assignments per-table, including
|
||||
// SqmParameter -> JdbcParameter mapping
|
||||
|
||||
void applySqlAssignments(
|
||||
Expression newValueExpression,
|
||||
AssignmentContext assignmentProcessingState,
|
||||
Consumer<Assignment> assignmentConsumer,
|
||||
SqlAstCreationContext creationContext);
|
||||
|
||||
interface AssignmentContext {
|
||||
}
|
||||
}
|
|
@ -4,23 +4,45 @@
|
|||
* 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.sql.results.spi;
|
||||
package org.hibernate.query.sqm.sql.internal;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.model.mapping.spi.SqlExpressableType;
|
||||
import org.hibernate.metamodel.mapping.SqlExpressableType;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Represents something that can produce a {@link DomainResult}
|
||||
* instances which can be used as selection items and
|
||||
* dynamic-instantiation args in a domain query.
|
||||
* Something that can produce a DomainResult as part of a SQM interpretation
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface DomainResultProducer<T> {
|
||||
|
||||
// this has to be designed as a bridge, but more geared toward the SQL
|
||||
|
||||
/*
|
||||
* select p.name, p2.name from Person p, Person p2
|
||||
*
|
||||
* SqmPathSource (SqmExpressable) (unmapped)
|
||||
*
|
||||
* DomainType
|
||||
* SimpleDomainType
|
||||
* ...
|
||||
*
|
||||
* MappingType
|
||||
*
|
||||
*
|
||||
*
|
||||
* ValueMapping (mapped)
|
||||
*
|
||||
*
|
||||
* ModelPartContainer personMapping = ...;
|
||||
* personMapping.getValueMapping( "name" );
|
||||
*/
|
||||
|
||||
/**
|
||||
* Visit all of the SqlExpressableTypes associated with this this Readable.
|
||||
*
|
||||
|
@ -35,7 +57,7 @@ public interface DomainResultProducer<T> {
|
|||
*/
|
||||
default DomainResult<T> createDomainResult(
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState){
|
||||
DomainResultCreationState creationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@ import org.hibernate.sql.results.spi.AssemblerCreationState;
|
|||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultAssembler;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.query.sqm.sql.internal;
|
||||
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.hibernate.sql.ast.Clause;
|
|||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -28,7 +27,6 @@ public class SqlAstQuerySpecProcessingStateImpl
|
|||
|
||||
private final QuerySpec querySpec;
|
||||
|
||||
private final Supplier<Consumer<DomainResult>> domainResultConsumerSupplier;
|
||||
private final Supplier<Consumer<SqlSelection>> sqlSelectionConsumerSupplier;
|
||||
|
||||
public SqlAstQuerySpecProcessingStateImpl(
|
||||
|
@ -37,11 +35,9 @@ public class SqlAstQuerySpecProcessingStateImpl
|
|||
SqlAstCreationState creationState,
|
||||
Supplier<Clause> currentClauseAccess,
|
||||
Supplier<Consumer<Expression>> resolvedExpressionConsumerAccess,
|
||||
Supplier<Consumer<DomainResult>> domainResultConsumerSupplier,
|
||||
Supplier<Consumer<SqlSelection>> sqlSelectionConsumerSupplier) {
|
||||
super( parent, creationState, currentClauseAccess, resolvedExpressionConsumerAccess );
|
||||
this.querySpec = querySpec;
|
||||
this.domainResultConsumerSupplier = domainResultConsumerSupplier;
|
||||
this.sqlSelectionConsumerSupplier = sqlSelectionConsumerSupplier;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.query.sqm.sql.internal;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
|
||||
/**
|
||||
* The interpretation of an SqmExpression as part of the SQM -> SQL conversion.
|
||||
*
|
||||
* Allows multi-column navigable references to be used anywhere a (SqlExpression)
|
||||
* can be. The trick is to properly define methods on this interface for how the
|
||||
* thing should be rendered into the SQL AST.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmExpressionInterpretation<T> extends SqmSelectableInterpretation<T> {
|
||||
SqmExpressable<T> getExpressableType();
|
||||
|
||||
default Expression toSqlExpression(SqmToSqlAstConverter walker, SqlAstCreationState sqlAstCreationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.query.sqm.sql.internal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.model.domain.internal.BasicSqmPathSource;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.sql.ConversionException;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.expression.SqlTuple;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmPathInterpretation<T> extends SqmExpressionInterpretation<T> {
|
||||
NavigablePath getNavigablePath();
|
||||
|
||||
@Override
|
||||
default SqmPathSource<T> getExpressableType() {
|
||||
return getSqmPathSource();
|
||||
}
|
||||
|
||||
SqmPathSource<T> getSqmPathSource();
|
||||
|
||||
@Override
|
||||
default Expression toSqlExpression(SqlAstCreationState sqlAstCreationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
// final TableGroup tableGroup;
|
||||
//
|
||||
// if ( getSqmPathSource() instanceof BasicSqmPathSource ) {
|
||||
// // maybe we should register the LHS TableGroup for the basic value
|
||||
// // under its NavigablePath, similar to what we do for embeddables
|
||||
// tableGroup = sqlAstCreationState.getFromClauseAccess().findTableGroup( getNavigablePath().getParent() );
|
||||
// }
|
||||
// else {
|
||||
// // for embeddable-, entity- and plural-valued Navigables we maybe do not have a TableGroup
|
||||
// final TableGroup thisTableGroup = sqlAstCreationState.getFromClauseAccess().findTableGroup( getNavigablePath() );
|
||||
// if ( thisTableGroup != null ) {
|
||||
// tableGroup = thisTableGroup;
|
||||
// }
|
||||
// else {
|
||||
// final NavigablePath lhsNavigablePath = getNavigablePath().getParent();
|
||||
// if ( lhsNavigablePath == null ) {
|
||||
// throw new ConversionException( "Could not find TableGroup to use - " + getNavigablePath().getFullPath() );
|
||||
// }
|
||||
// tableGroup = sqlAstCreationState.getFromClauseAccess().findTableGroup( lhsNavigablePath );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// sqlAstCreationState.getCreationContext().getDomainModel().resolveMappingExpressable( )
|
||||
//
|
||||
// final List list = getNavigable().resolveColumnReferences( tableGroup, sqlAstCreationState );
|
||||
// if ( list.size() == 1 ) {
|
||||
// assert list.get( 0 ) instanceof Expression;
|
||||
// return (Expression) list.get( 0 );
|
||||
// }
|
||||
//
|
||||
// return new SqlTuple( list, sqlAstCreationState.getExpressableType() );
|
||||
}
|
||||
}
|
|
@ -31,7 +31,6 @@ import org.hibernate.query.spi.QueryParameterBindings;
|
|||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqlAstQuerySpecProcessingState;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmEnumLiteral;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmFieldLiteral;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType;
|
||||
|
@ -51,12 +50,10 @@ import org.hibernate.sql.ast.tree.from.TableGroup;
|
|||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
import org.hibernate.sql.ast.tree.select.SelectClause;
|
||||
import org.hibernate.sql.ast.tree.select.SelectStatement;
|
||||
import org.hibernate.sql.results.spi.CircularFetchDetector;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.sql.results.spi.Fetch;
|
||||
import org.hibernate.sql.results.spi.FetchParent;
|
||||
import org.hibernate.sql.results.spi.Fetchable;
|
||||
|
@ -74,6 +71,8 @@ public class SqmSelectToSqlAstConverter
|
|||
implements DomainResultCreationState {
|
||||
private final CircularFetchDetector circularFetchDetector = new CircularFetchDetector();
|
||||
|
||||
private final List<DomainResult> domainResults = new ArrayList<>();
|
||||
|
||||
public SqmSelectToSqlAstConverter(
|
||||
QueryOptions queryOptions,
|
||||
DomainParameterXref domainParameterXref,
|
||||
|
@ -111,41 +110,36 @@ public class SqmSelectToSqlAstConverter
|
|||
public SelectStatement visitSelectStatement(SqmSelectStatement statement) {
|
||||
final QuerySpec querySpec = visitQuerySpec( statement.getQuerySpec() );
|
||||
|
||||
return new SelectStatement( querySpec );
|
||||
return new SelectStatement( querySpec, domainResults );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void visitSelection(SqmSelection sqmSelection) {
|
||||
// todo (6.0) : this should actually be able to generate multiple SqlSelections
|
||||
final DomainResultProducer resultProducer = (DomainResultProducer) sqmSelection.getSelectableNode().accept( this );
|
||||
final DomainResultProducer resultProducer = resolveDomainResultProducer( sqmSelection );
|
||||
|
||||
if ( getProcessingStateStack().depth() > 1 ) {
|
||||
resultProducer.applySqlSelections( this );
|
||||
}
|
||||
else {
|
||||
|
||||
final SelectClause selectClause = ( (SqlAstQuerySpecProcessingState) getCurrentProcessingState() )
|
||||
.getInflightQuerySpec()
|
||||
.getSelectClause();
|
||||
final DomainResult domainResult = resultProducer.createDomainResult(
|
||||
sqmSelection.getAlias(),
|
||||
this
|
||||
);
|
||||
|
||||
selectClause
|
||||
.addSelection( domainResult );
|
||||
domainResults.add( domainResult );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int fetchDepth = 0;
|
||||
|
||||
private int currentFetchDepth() {
|
||||
return fetchDepth;
|
||||
private DomainResultProducer resolveDomainResultProducer(SqmSelection sqmSelection) {
|
||||
return ( (SqmExpressionInterpretation) sqmSelection.getSelectableNode() ).getDomainResultProducer( this, this );
|
||||
}
|
||||
|
||||
private int fetchDepth = 0;
|
||||
|
||||
@Override
|
||||
public List<Fetch> visitFetches(FetchParent fetchParent) {
|
||||
final List<Fetch> fetches = new ArrayList();
|
||||
|
@ -394,24 +388,6 @@ public class SqmSelectToSqlAstConverter
|
|||
// .getOrMakeJavaDescriptor( namedClass );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitEnumLiteral(SqmEnumLiteral sqmEnumLiteral) {
|
||||
return new QueryLiteral(
|
||||
sqmEnumLiteral.getEnumValue(),
|
||||
determineValueMapping( sqmEnumLiteral ),
|
||||
getCurrentClauseStack().getCurrent()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitFieldLiteral(SqmFieldLiteral sqmFieldLiteral) {
|
||||
return new QueryLiteral(
|
||||
sqmFieldLiteral.getValue(),
|
||||
determineValueMapping( sqmFieldLiteral ),
|
||||
getCurrentClauseStack().getCurrent()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public SqlSelection resolveSqlSelection(Expression expression) {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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.query.sqm.sql.internal;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmSelectableInterpretation<T> {
|
||||
default DomainResultProducer<T> getDomainResultProducer(SqmToSqlAstConverter walker, SqlAstCreationState sqlAstCreationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.query.sqm.sql.internal;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.query.sqm.sql.ConversionException;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class SqmSqlHelper {
|
||||
private SqmSqlHelper() {
|
||||
}
|
||||
|
||||
public static TableGroup resolveTableGroup(SqmPath<?> sqmPath, SqlAstCreationState creationState) {
|
||||
SqmPath<?> lhs = sqmPath;
|
||||
while ( lhs.getReferencedPathSource().getSqmPathType() instanceof EmbeddableDomainType ) {
|
||||
lhs = lhs.getLhs();
|
||||
}
|
||||
|
||||
final TableGroup tableGroup = creationState.getFromClauseAccess().findTableGroup( lhs.getNavigablePath() );
|
||||
if ( tableGroup != null ) {
|
||||
return tableGroup;
|
||||
}
|
||||
|
||||
throw new ConversionException( "Could not locate TableGroup to use : " + lhs.getNavigablePath() );
|
||||
}
|
||||
}
|
|
@ -159,6 +159,8 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
|||
|
||||
final DomainType sqmNodeType = getReferencedPathSource().getSqmPathType();
|
||||
|
||||
final String mappingRoleName = getReferencedPathSource().getMappingRole() + '.' + discriminatorPathName;
|
||||
|
||||
if ( sqmNodeType instanceof EntityDomainType ) {
|
||||
final SqmPathSource discriminatorPathSource = new SqmPathSource() {
|
||||
@Override
|
||||
|
@ -166,8 +168,14 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
|||
return discriminatorPathName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappingRole() {
|
||||
return mappingRoleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainType<?> getSqmPathType() {
|
||||
// the BasicType for Class?
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import org.hibernate.query.NavigablePath;
|
|||
import org.hibernate.query.PathException;
|
||||
import org.hibernate.query.SemanticException;
|
||||
import org.hibernate.query.hql.spi.SemanticPathPart;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.hibernate.query.sqm.NodeBuilder;
|
|||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
|
||||
|
@ -84,11 +84,6 @@ public class SqmMapEntryReference<K,V>
|
|||
return walker.visitMapEntryFunction( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<Map.Entry<K, V>> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSubSelectableNodes(Consumer<SqmSelectableNode<?>> jpaSelectionConsumer) {
|
||||
}
|
||||
|
|
|
@ -15,13 +15,12 @@ import org.hibernate.query.PathException;
|
|||
import org.hibernate.query.SemanticException;
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
import org.hibernate.query.hql.spi.SemanticPathPart;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.ParsingException;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<T>, DomainResultProducer<T> {
|
||||
public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<T> {
|
||||
|
||||
/**
|
||||
* Returns the NavigablePath.
|
||||
|
@ -46,11 +45,6 @@ public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<
|
|||
*/
|
||||
SqmPathSource<?> getReferencedPathSource();
|
||||
|
||||
@Override
|
||||
default DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the explicit alias, if one. May return null
|
||||
*/
|
||||
|
|
|
@ -11,15 +11,17 @@ import java.util.function.Consumer;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.mapping.SqlExpressableType;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
|
||||
import org.hibernate.metamodel.model.mapping.spi.SqlExpressableType;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.PathException;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.hql.spi.SqmCreationProcessingState;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.tree.SqmJoinType;
|
||||
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmFrom;
|
||||
|
@ -30,7 +32,7 @@ import org.hibernate.type.spi.TypeConfiguration;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
|
||||
public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> implements DomainResultProducer<T> {
|
||||
public SqmSingularJoin(
|
||||
SqmFrom<?,O> lhs,
|
||||
SingularPersistentAttribute<O, T> joinedNavigable,
|
||||
|
@ -98,7 +100,7 @@ public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
|
|||
final EntityPersister entityDescriptor = typeConfiguration.getSessionFactory()
|
||||
.getMetamodel()
|
||||
.getEntityDescriptor( entityName );
|
||||
entityDescriptor.visitValueMappings(
|
||||
entityDescriptor.visitSubParts(
|
||||
valueMapping -> valueMapping.getBindable().visitJdbcTypes(
|
||||
action,
|
||||
Clause.IRRELEVANT,
|
||||
|
|
|
@ -31,6 +31,11 @@ public abstract class AbstractSqmExpression<T> extends AbstractJpaSelection<T> i
|
|||
super( type, criteriaBuilder );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmExpressable<T> getExpressableType() {
|
||||
return getNodeType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void applyInferableType(SqmExpressable<?> type) {
|
||||
if ( type == null ) {
|
||||
|
|
|
@ -9,14 +9,14 @@ package org.hibernate.query.sqm.tree.expression;
|
|||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||
import org.hibernate.query.BinaryArithmeticOperator;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmBinaryArithmetic<T> extends AbstractSqmExpression<T> implements DomainResultProducer<T> {
|
||||
public class SqmBinaryArithmetic<T> extends AbstractSqmExpression<T> implements SqmSelectableNode<T> {
|
||||
private final SqmExpression<?> lhsOperand;
|
||||
private final BinaryArithmeticOperator operator;
|
||||
private final SqmExpression<?> rhsOperand;
|
||||
|
@ -106,8 +106,4 @@ public class SqmBinaryArithmetic<T> extends AbstractSqmExpression<T> implements
|
|||
return getOperator().toLoggableText( lhsOperand.asLoggableText(), rhsOperand.asLoggableText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.query.sqm.NodeBuilder;
|
|||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -126,8 +126,4 @@ public class SqmCaseSearched<R>
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<R> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.query.criteria.JpaSimpleCase;
|
|||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -139,8 +139,4 @@ public class SqmCaseSimple<T,R>
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<R> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.hibernate.query.sqm.NodeBuilder;
|
|||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
/**
|
||||
|
@ -45,12 +45,7 @@ public class SqmCollectionSize extends AbstractSqmExpression<Integer> implements
|
|||
return "SIZE(" + pluralPath.asLoggableText() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<Integer> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Override
|
||||
// public DomainResult createDomainResult(
|
||||
// String resultVariable,
|
||||
// DomainResultCreationState creationState) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.query.spi.QueryParameterImplementor;
|
|||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* SqmParameter created via JPA {@link javax.persistence.criteria.CriteriaBuilder}
|
||||
|
@ -121,9 +121,4 @@ public class SqmCriteriaParameter<T>
|
|||
public NamedCallableQueryMemento.ParameterMemento toMemento() {
|
||||
throw new UnsupportedOperationException( "ParameterMemento cannot be extracted from Criteria query parameter" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,17 @@ package org.hibernate.query.sqm.tree.expression;
|
|||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
|
||||
/**
|
||||
* Entity type expression based on a parameter - `TYPE( :someParam )`
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmEntityType<T> extends AbstractSqmExpression<T> implements DomainResultProducer<T> {
|
||||
public class SqmEntityType<T> extends AbstractSqmExpression<T> implements SqmSelectableNode<T> {
|
||||
private final SqmExpression discriminatorSource;
|
||||
|
||||
public SqmEntityType(SqmParameter<T> parameterExpression, NodeBuilder nodeBuilder) {
|
||||
|
@ -45,10 +45,4 @@ public class SqmEntityType<T> extends AbstractSqmExpression<T> implements Domain
|
|||
return walker.visitParameterizedEntityTypeExpression( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
// technically `T` should be `Class<T>` here
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,13 +16,12 @@ import javax.persistence.criteria.Expression;
|
|||
import org.hibernate.query.SemanticException;
|
||||
import org.hibernate.query.criteria.JpaSelection;
|
||||
import org.hibernate.query.hql.spi.SemanticPathPart;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
|
@ -32,7 +31,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmEnumLiteral implements SqmExpression<Enum>, SqmExpressable<Enum>, DomainResultProducer<Enum>, SemanticPathPart {
|
||||
public class SqmEnumLiteral implements SqmExpression<Enum>, SqmExpressable<Enum>, SemanticPathPart {
|
||||
private final Enum enumValue;
|
||||
private final EnumJavaTypeDescriptor<Enum> referencedEnumTypeDescriptor;
|
||||
private final String enumValueName;
|
||||
|
@ -66,6 +65,11 @@ public class SqmEnumLiteral implements SqmExpression<Enum>, SqmExpressable<Enum>
|
|||
return referencedEnumTypeDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmExpressable<Enum> getExpressableType() {
|
||||
return expressable;
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// SemanticPathPart
|
||||
|
@ -216,9 +220,4 @@ public class SqmEnumLiteral implements SqmExpression<Enum>, SqmExpressable<Enum>
|
|||
public String getAlias() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<Enum> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
|
|||
import org.hibernate.metamodel.model.domain.DomainType;
|
||||
import org.hibernate.query.criteria.JpaExpression;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.SqmExpressionInterpretation;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
|
||||
|
@ -28,7 +29,7 @@ import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmExpression<T> extends SqmSelectableNode<T>, JpaExpression<T> {
|
||||
public interface SqmExpression<T> extends SqmSelectableNode<T>, JpaExpression<T>, SqmExpressionInterpretation<T> {
|
||||
/**
|
||||
* The expression's type.
|
||||
*
|
||||
|
|
|
@ -18,19 +18,19 @@ import org.hibernate.QueryException;
|
|||
import org.hibernate.query.SemanticException;
|
||||
import org.hibernate.query.criteria.JpaSelection;
|
||||
import org.hibernate.query.hql.spi.SemanticPathPart;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmFieldLiteral<T> implements SqmExpression<T>, SqmExpressable<T>, DomainResultProducer<T>, SemanticPathPart {
|
||||
public class SqmFieldLiteral<T> implements SqmExpression<T>, SqmExpressable<T>, SqmSelectableNode<T>, SemanticPathPart {
|
||||
private final T value;
|
||||
private final JavaTypeDescriptor<T> fieldJavaTypeDescriptor;
|
||||
private final String fieldName;
|
||||
|
@ -77,6 +77,11 @@ public class SqmFieldLiteral<T> implements SqmExpression<T>, SqmExpressable<T>,
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmExpressable<T> getExpressableType() {
|
||||
return expressable;
|
||||
}
|
||||
|
||||
public JavaTypeDescriptor<T> getFieldJavaTypeDescriptor() {
|
||||
return fieldJavaTypeDescriptor;
|
||||
}
|
||||
|
@ -252,8 +257,4 @@ public class SqmFieldLiteral<T> implements SqmExpression<T>, SqmExpressable<T>,
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.query.sqm.tree.expression;
|
|||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Represents a literal value in the sqm, e.g.<ul>
|
||||
|
@ -45,8 +45,4 @@ public class SqmLiteral<T>
|
|||
return "Literal( " + value + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
package org.hibernate.query.sqm.tree.expression;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.query.hql.spi.SemanticPathPart;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.hql.HqlInterpretationException;
|
||||
import org.hibernate.query.hql.spi.SemanticPathPart;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|||
*/
|
||||
public class SqmLiteralEntityType<T>
|
||||
extends AbstractSqmExpression<T>
|
||||
implements DomainResultProducer<T>, SemanticPathPart {
|
||||
implements SqmSelectableNode<T>, SemanticPathPart {
|
||||
private final EntityDomainType<T> entityType;
|
||||
|
||||
public SqmLiteralEntityType(EntityDomainType<T> entityType, NodeBuilder nodeBuilder) {
|
||||
|
@ -85,9 +85,4 @@ public class SqmLiteralEntityType<T>
|
|||
throw new HqlInterpretationException( "Cannot dereference an entity name" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
// technically `T` should be `Class<T>` here
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.query.sqm.tree.expression;
|
|||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Represents a named query parameter in the SQM tree.
|
||||
|
@ -37,11 +36,6 @@ public class SqmNamedParameter<T> extends AbstractSqmParameter<T> {
|
|||
return walker.visitNamedParameterExpression( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
throw new UnsupportedOperationException( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asLoggableText() {
|
||||
return ":" + getName();
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.query.sqm.tree.expression;
|
|||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Models a positional parameter expression
|
||||
|
@ -55,8 +54,4 @@ public class SqmPositionalParameter<T> extends AbstractSqmParameter<T> {
|
|||
return "?" + getPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
throw new UnsupportedOperationException( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
package org.hibernate.query.sqm.tree.expression;
|
||||
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSubQuery;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Represents a {@link Modifier#ALL}, {@link Modifier#ANY}, {@link Modifier#SOME} modifier appplied to a subquery as
|
||||
|
@ -62,9 +61,4 @@ public class SqmRestrictedSubQueryExpression<T> extends AbstractSqmExpression<T>
|
|||
public <X> X accept(SemanticQueryWalker<X> walker) {
|
||||
return walker.visitRestrictedSubQueryExpression( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return subQuery.getDomainResultProducer();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.query.sqm.tree.expression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -13,10 +14,15 @@ import org.hibernate.QueryException;
|
|||
import org.hibernate.query.criteria.JpaCompoundSelection;
|
||||
import org.hibernate.query.criteria.JpaSelection;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.SqmExpressionInterpretation;
|
||||
import org.hibernate.query.sqm.tree.select.SqmJpaCompoundSelection;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.expression.SqlTuple;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +35,9 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmTuple<T> extends AbstractSqmExpression<T> implements JpaCompoundSelection<T> {
|
||||
public class SqmTuple<T>
|
||||
extends AbstractSqmExpression<T>
|
||||
implements JpaCompoundSelection<T>, SqmExpressionInterpretation<T> {
|
||||
private final List<SqmExpression<?>> groupedExpressions;
|
||||
|
||||
public SqmTuple(NodeBuilder nodeBuilder, SqmExpression<?>... groupedExpressions) {
|
||||
|
@ -77,6 +85,36 @@ public class SqmTuple<T> extends AbstractSqmExpression<T> implements JpaCompound
|
|||
return walker.visitTuple( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression toSqlExpression(
|
||||
SqmToSqlAstConverter walker,
|
||||
SqlAstCreationState sqlAstCreationState) {
|
||||
final List<Expression> groupedSqlExpressions = new ArrayList<>();
|
||||
|
||||
for ( SqmExpression groupedExpression : groupedExpressions ) {
|
||||
final SqmExpressionInterpretation interpretation = (SqmExpressionInterpretation) groupedExpression.accept( walker );
|
||||
final Expression sqlExpression = interpretation.toSqlExpression(
|
||||
walker,
|
||||
sqlAstCreationState
|
||||
);
|
||||
|
||||
groupedSqlExpressions.add( sqlExpression );
|
||||
}
|
||||
|
||||
return new SqlTuple(
|
||||
groupedSqlExpressions,
|
||||
sqlAstCreationState.getCreationContext().getDomainModel()
|
||||
.resolveMappingExpressable( getExpressableType() )
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer getDomainResultProducer(
|
||||
SqmToSqlAstConverter walker,
|
||||
SqlAstCreationState sqlAstCreationState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asLoggableText() {
|
||||
return toString();
|
||||
|
@ -97,9 +135,4 @@ public class SqmTuple<T> extends AbstractSqmExpression<T> implements JpaCompound
|
|||
return groupedExpressions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
// could technically return an array I guess
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
package org.hibernate.query.sqm.tree.expression;
|
||||
|
||||
import org.hibernate.query.UnaryArithmeticOperator;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmUnaryOperation<T> extends AbstractSqmExpression<T> implements DomainResultProducer<T> {
|
||||
public class SqmUnaryOperation<T> extends AbstractSqmExpression<T> implements SqmSelectableNode<T> {
|
||||
private final UnaryArithmeticOperator operation;
|
||||
private final SqmExpression operand;
|
||||
|
||||
|
@ -41,11 +41,6 @@ public class SqmUnaryOperation<T> extends AbstractSqmExpression<T> implements Do
|
|||
return operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> X accept(SemanticQueryWalker<X> walker) {
|
||||
return walker.visitUnaryOperationExpression( this );
|
||||
|
|
|
@ -8,18 +8,24 @@ package org.hibernate.query.sqm.tree.from;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.mapping.SqlExpressableType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.mapping.spi.SqlExpressableType;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.PathException;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.tree.domain.AbstractSqmFrom;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmTreatedPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmTreatedRoot;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
@ -28,7 +34,7 @@ import org.hibernate.type.spi.TypeConfiguration;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E> {
|
||||
public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E>, DomainResultProducer<E> {
|
||||
public SqmRoot(
|
||||
EntityDomainType<E> entityType,
|
||||
String alias,
|
||||
|
@ -97,13 +103,27 @@ public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E> {
|
|||
return new SqmTreatedRoot<>( this, treatTarget, nodeBuilder() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<E> getDomainResultProducer(
|
||||
SqmToSqlAstConverter walker,
|
||||
SqlAstCreationState sqlAstCreationState) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression toSqlExpression(
|
||||
SqmToSqlAstConverter walker,
|
||||
SqlAstCreationState sqlAstCreationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJdbcTypes(Consumer<SqlExpressableType> action, TypeConfiguration typeConfiguration) {
|
||||
final String entityName = getReferencedPathSource().getHibernateEntityName();
|
||||
final EntityPersister entityDescriptor = typeConfiguration.getSessionFactory()
|
||||
.getMetamodel()
|
||||
.getEntityDescriptor( entityName );
|
||||
entityDescriptor.visitValueMappings(
|
||||
entityDescriptor.visitSubParts(
|
||||
valueMapping -> valueMapping.getBindable().visitJdbcTypes(
|
||||
action,
|
||||
Clause.IRRELEVANT,
|
||||
|
@ -112,6 +132,7 @@ public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E> {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DomainResult<E> createDomainResult(
|
||||
String resultVariable,
|
||||
|
@ -123,6 +144,7 @@ public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E> {
|
|||
.getEntityDescriptor( entityName );
|
||||
return entityDescriptor.createDomainResult(
|
||||
getNavigablePath(),
|
||||
creationState.getSqlAstCreationState().getFromClauseAccess().findTableGroup( getNavigablePath() ),
|
||||
resultVariable,
|
||||
creationState
|
||||
);
|
||||
|
@ -135,7 +157,11 @@ public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E> {
|
|||
.getCreationContext()
|
||||
.getDomainModel()
|
||||
.getEntityDescriptor( entityName );
|
||||
entityDescriptor.applySqlSelections( getNavigablePath(), creationState );
|
||||
entityDescriptor.applySqlSelections(
|
||||
getNavigablePath(),
|
||||
creationState.getSqlAstCreationState().getFromClauseAccess().findTableGroup( getNavigablePath() ),
|
||||
creationState
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.query.sqm.tree.predicate;
|
|||
import org.hibernate.query.criteria.JpaPredicate;
|
||||
import org.hibernate.query.sqm.tree.SqmVisitableNode;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
|
@ -26,8 +26,4 @@ public interface SqmPredicate
|
|||
@Override
|
||||
SqmPredicate not();
|
||||
|
||||
@Override
|
||||
default DomainResultProducer<Boolean> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public abstract class AbstractSqmSelectQuery<T>
|
|||
this.resultType = sqmQuerySpec.getSelectClause().getJavaType();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class getResultType() {
|
||||
return resultType;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.query.sqm.tree.select;
|
|||
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Models any aliased expression. E.g. `select exp as e ...`
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.query.sqm.NodeBuilder;
|
|||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.query.sqm.tree.jpa.AbstractJpaSelection;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -118,11 +118,6 @@ public class SqmDynamicInstantiation<T>
|
|||
return getInstantiationTarget().getTargetTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asLoggableText() {
|
||||
return "<new " + instantiationTarget.getJavaType().getName() + ">";
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.query.sqm.NodeBuilder;
|
|||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -109,9 +109,4 @@ public class SqmJpaCompoundSelection<T>
|
|||
return walker.visitJpaCompoundSelection( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
// could technically return an array I guess. See `SqmTuple`
|
||||
throw new UnsupportedOperationException( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,14 @@ package org.hibernate.query.sqm.tree.select;
|
|||
import java.util.function.Consumer;
|
||||
import javax.persistence.criteria.Selection;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.query.criteria.JpaSelection;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.SqmSelectableInterpretation;
|
||||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||
import org.hibernate.query.sqm.tree.SqmVisitableNode;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* Defines a SQM AST node that can be used as a selection in the query,
|
||||
|
@ -20,12 +24,7 @@ import org.hibernate.sql.results.spi.DomainResultProducer;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqmSelectableNode<T> extends JpaSelection<T>, SqmTypedNode<T>, SqmVisitableNode {
|
||||
/**
|
||||
* Get the DomainResultProducer for this SqmSelectableNode
|
||||
*/
|
||||
DomainResultProducer<T> getDomainResultProducer();
|
||||
|
||||
public interface SqmSelectableNode<T> extends JpaSelection<T>, SqmTypedNode<T>, SqmVisitableNode, SqmSelectableInterpretation<T> {
|
||||
/**
|
||||
* Visit each of this selectable's direct sub-selectables - used to
|
||||
* support JPA's {@link Selection} model (which is really a "selectable",
|
||||
|
@ -35,4 +34,8 @@ public interface SqmSelectableNode<T> extends JpaSelection<T>, SqmTypedNode<T>,
|
|||
* @see Selection#getCompoundSelectionItems()
|
||||
*/
|
||||
void visitSubSelectableNodes(Consumer<SqmSelectableNode<?>> jpaSelectionConsumer);
|
||||
|
||||
default DomainResultProducer<T> getDomainResultProducer(SqmToSqlAstConverter walker, SqlAstCreationState sqlAstCreationState) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
|||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmInPredicate;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
|
@ -73,6 +72,11 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
|
|||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmExpressable<T> getExpressableType() {
|
||||
return expressableType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmQuery<?> getContainingQuery() {
|
||||
return parent;
|
||||
|
@ -313,8 +317,4 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
|
|||
return walker.visitSubQueryExpression( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResultProducer<T> getDomainResultProducer() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* 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.sql.ast;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
|
||||
/**
|
||||
* Something that is expressable at the mapping-model type level as a type for
|
||||
* `SqlExpression` whether the SQL AST node is simple or compound.
|
||||
*
|
||||
* todo (6.0) : in that case it seems like `SqlExpression` should be a `ValueMappingExpressable`. `SqlTuple` is
|
||||
* a special case for compound expressions - the `ValueMapping` would be the "composite type"
|
||||
*
|
||||
* todo (6.0) : does adding a SqlAstExpressionProducer make sense?
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ValueMappingExpressable {
|
||||
/**
|
||||
* The ValueMapping for this expressable
|
||||
*/
|
||||
ValueMapping getExpressableValueMapping();
|
||||
}
|
|
@ -10,15 +10,14 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.sql.exec.spi.ExecutionContext;
|
||||
import org.hibernate.sql.exec.spi.JdbcParameterBinder;
|
||||
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* We classify literals different based on their source so that we can handle then differently
|
||||
|
@ -29,12 +28,12 @@ import org.hibernate.sql.results.spi.DomainResultProducer;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractLiteral
|
||||
implements JdbcParameterBinder, Expression, ValueMappingExpressable, DomainResultProducer {
|
||||
implements JdbcParameterBinder, Expression, DomainResultProducer {
|
||||
private final Object value;
|
||||
private final ValueMappingExpressable type;
|
||||
private final MappingModelExpressable type;
|
||||
private final Clause clause;
|
||||
|
||||
public AbstractLiteral(Object value, ValueMappingExpressable type, Clause clause) {
|
||||
public AbstractLiteral(Object value, MappingModelExpressable type, Clause clause) {
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.clause = clause;
|
||||
|
@ -44,15 +43,15 @@ public abstract class AbstractLiteral
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping getExpressableValueMapping() {
|
||||
return type.getExpressableValueMapping();
|
||||
}
|
||||
|
||||
public boolean isInSelect() {
|
||||
return clause == Clause.SELECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult createDomainResult(
|
||||
String resultVariable,
|
||||
|
@ -61,7 +60,6 @@ public abstract class AbstractLiteral
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindParameterValue(
|
||||
PreparedStatement statement,
|
||||
int startPosition,
|
||||
|
@ -70,9 +68,4 @@ public abstract class AbstractLiteral
|
|||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
// getType().getJdbcValueBinder().bind( statement, startPosition, value, executionContext );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,32 +4,29 @@
|
|||
* 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.sql.ast.tree.expression;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.query.BinaryArithmeticOperator;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BinaryArithmeticExpression
|
||||
implements Expression, ValueMappingExpressable, DomainResultProducer {
|
||||
public class BinaryArithmeticExpression implements Expression, DomainResultProducer {
|
||||
|
||||
private final Expression lhsOperand;
|
||||
private final BinaryArithmeticOperator operator;
|
||||
private final Expression rhsOperand;
|
||||
|
||||
private final ValueMappingExpressable resultType;
|
||||
private final MappingModelExpressable resultType;
|
||||
|
||||
public BinaryArithmeticExpression(
|
||||
Expression lhsOperand,
|
||||
BinaryArithmeticOperator operator,
|
||||
Expression rhsOperand,
|
||||
ValueMappingExpressable resultType) {
|
||||
MappingModelExpressable resultType) {
|
||||
this.operator = operator;
|
||||
this.lhsOperand = lhsOperand;
|
||||
this.rhsOperand = rhsOperand;
|
||||
|
@ -37,12 +34,7 @@ public class BinaryArithmeticExpression
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping getExpressableValueMapping() {
|
||||
return resultType.getExpressableValueMapping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return resultType;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,24 +11,23 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CaseSearchedExpression implements Expression, ValueMappingExpressable, DomainResultProducer {
|
||||
private final ValueMappingExpressable type;
|
||||
public class CaseSearchedExpression implements Expression, DomainResultProducer {
|
||||
private final MappingModelExpressable type;
|
||||
|
||||
private List<WhenFragment> whenFragments = new ArrayList<>();
|
||||
private Expression otherwise;
|
||||
|
||||
public CaseSearchedExpression(ValueMappingExpressable type) {
|
||||
public CaseSearchedExpression(MappingModelExpressable type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
@ -72,15 +71,7 @@ public class CaseSearchedExpression implements Expression, ValueMappingExpressab
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping getExpressableValueMapping() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
if ( type == null ) {
|
||||
return this;
|
||||
}
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,24 +11,24 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CaseSimpleExpression implements Expression, ValueMappingExpressable, DomainResultProducer {
|
||||
private final ValueMappingExpressable type;
|
||||
public class CaseSimpleExpression implements Expression, DomainResultProducer {
|
||||
private final MappingModelExpressable type;
|
||||
private final Expression fixture;
|
||||
|
||||
private List<WhenFragment> whenFragments = new ArrayList<>();
|
||||
private Expression otherwise;
|
||||
|
||||
public CaseSimpleExpression(ValueMappingExpressable type, Expression fixture) {
|
||||
public CaseSimpleExpression(MappingModelExpressable type, Expression fixture) {
|
||||
this.type = type;
|
||||
this.fixture = fixture;
|
||||
}
|
||||
|
@ -38,15 +38,10 @@ public class CaseSimpleExpression implements Expression, ValueMappingExpressable
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping getExpressableValueMapping() {
|
||||
return type.getExpressableValueMapping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(SqlAstWalker walker) {
|
||||
walker.visitCaseSimpleExpression( this );
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.util.Objects;
|
|||
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.model.mapping.spi.SqlExpressableType;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.metamodel.mapping.SqlExpressableType;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||
|
@ -78,8 +78,8 @@ public class ColumnReference implements Expression {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
return (ValueMappingExpressable) sqlExpressableType;
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return (MappingModelExpressable) sqlExpressableType;
|
||||
}
|
||||
|
||||
public String renderSqlFragment() {
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.sql.ast.tree.expression;
|
||||
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Queryable;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
|
@ -30,13 +29,9 @@ public class EntityTypeLiteral implements Expression {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
return () -> new ValueMapping() {
|
||||
@Override
|
||||
public Type getValueType() {
|
||||
return discriminatorType;
|
||||
}
|
||||
};
|
||||
public ModelPart getExpressionType() {
|
||||
// todo (6.0) : entity descriptor or its discriminator descriptor?
|
||||
return entityTypeDescriptor;
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package org.hibernate.sql.ast.tree.expression;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.spi.SqlSelectionProducer;
|
||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||
|
@ -23,7 +23,7 @@ public interface Expression extends SqlAstNode, SqlSelectionProducer {
|
|||
/**
|
||||
* The type for this expression
|
||||
*/
|
||||
ValueMappingExpressable getExpressionType();
|
||||
MappingModelExpressable getExpressionType();
|
||||
|
||||
@Override
|
||||
default SqlSelection createSqlSelection(
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.sql.ast.tree.expression;
|
||||
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ import org.hibernate.sql.ast.spi.SqlAstWalker;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class QueryLiteral extends AbstractLiteral {
|
||||
public QueryLiteral(Object value, ValueMappingExpressable expressableType, Clause clause) {
|
||||
public QueryLiteral(Object value, MappingModelExpressable expressableType, Clause clause) {
|
||||
super( value, expressableType, clause );
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.sql.ast.tree.expression;
|
||||
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public class SqlSelectionExpression implements Expression {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return theExpression.getExpressionType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.sql.ast.tree.expression;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
|
||||
/**
|
||||
|
@ -17,20 +16,16 @@ import org.hibernate.sql.ast.spi.SqlAstWalker;
|
|||
*/
|
||||
public class SqlTuple implements Expression {
|
||||
private final List<? extends Expression> expressions;
|
||||
private final ValueMappingExpressable expressable;
|
||||
private final MappingModelExpressable valueMapping;
|
||||
|
||||
public SqlTuple(List<? extends Expression> expressions, ValueMappingExpressable expressable) {
|
||||
public SqlTuple(List<? extends Expression> expressions, MappingModelExpressable valueMapping) {
|
||||
this.expressions = expressions;
|
||||
this.expressable = expressable;
|
||||
}
|
||||
|
||||
public SqlTuple(Expression expression, ValueMappingExpressable expressable) {
|
||||
this( Collections.singletonList( expression ), expressable );
|
||||
this.valueMapping = valueMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
return expressable;
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return valueMapping;
|
||||
}
|
||||
|
||||
public List<? extends Expression> getExpressions(){
|
||||
|
|
|
@ -8,25 +8,25 @@
|
|||
package org.hibernate.sql.ast.tree.expression;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.query.UnaryArithmeticOperator;
|
||||
import org.hibernate.sql.ast.ValueMappingExpressable;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.DomainResultProducer;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class UnaryOperation implements Expression, ValueMappingExpressable, DomainResultProducer {
|
||||
public class UnaryOperation implements Expression, DomainResultProducer {
|
||||
|
||||
private final UnaryArithmeticOperator operator;
|
||||
|
||||
private final Expression operand;
|
||||
private final ValueMappingExpressable type;
|
||||
private final MappingModelExpressable type;
|
||||
|
||||
public UnaryOperation(UnaryArithmeticOperator operator, Expression operand, ValueMappingExpressable type) {
|
||||
public UnaryOperation(UnaryArithmeticOperator operator, Expression operand, MappingModelExpressable type) {
|
||||
this.operator = operator;
|
||||
this.operand = operand;
|
||||
this.type = type;
|
||||
|
@ -41,16 +41,10 @@ public class UnaryOperation implements Expression, ValueMappingExpressable, Doma
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueMappingExpressable getExpressionType() {
|
||||
public MappingModelExpressable getExpressionType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueMapping getExpressableValueMapping() {
|
||||
// calling type#getExpressableValueMapping could be recursive
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(SqlAstWalker walker) {
|
||||
walker.visitUnaryOperationExpression( this );
|
||||
|
|
|
@ -114,25 +114,6 @@ public abstract class AbstractTableGroup implements TableGroup {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder buffer = new StringBuilder( "(" );
|
||||
|
||||
buffer.append( "path=(" ).append( getNavigablePath() ).append( "), " );
|
||||
buffer.append( "root=(" ).append( getPrimaryTableReference() ).append( "), " );
|
||||
buffer.append( "joins=[" );
|
||||
if ( getTableReferenceJoins() != null ) {
|
||||
boolean firstPass = true;
|
||||
for ( TableReferenceJoin tableReferenceJoin : getTableReferenceJoins() ) {
|
||||
if ( firstPass ) {
|
||||
firstPass = false;
|
||||
}
|
||||
else {
|
||||
buffer.append( ',' );
|
||||
}
|
||||
|
||||
buffer.append( tableReferenceJoin );
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.append( "])" ).toString();
|
||||
return getClass().getSimpleName() + '(' + getNavigablePath() + ')';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package org.hibernate.sql.ast.tree.from;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.metamodel.model.mapping.spi.ValueMappingContainer;
|
||||
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.sql.ast.JoinType;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||
|
@ -19,7 +19,7 @@ import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface RootTableGroupProducer extends TableGroupProducer, ValueMappingContainer {
|
||||
public interface RootTableGroupProducer extends TableGroupProducer, ModelPartContainer {
|
||||
/**
|
||||
* Create a root TableGroup as defined by this producer
|
||||
*/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue