Rebase main -> 7.0
This commit is contained in:
parent
3a0d02bde6
commit
724f2547bc
|
@ -32,7 +32,7 @@ public class WrappedInferredData implements PropertyData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XClass getClassOrPluralElement() throws MappingException {
|
||||
public ClassDetails getClassOrPluralElement() throws MappingException {
|
||||
return wrappedInferredData.getClassOrPluralElement();
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ public abstract class AbstractSaveEventListener<C>
|
|||
processIfManagedEntity( entity, (managedEntity) -> managedEntity.$$_hibernate_setUseTracker( true ) );
|
||||
|
||||
final Generator generator = persister.getGenerator();
|
||||
if ( generator instanceof Assigned || generator instanceof CompositeNestedGeneratedValueGenerator ) {
|
||||
if ( !generator.generatesOnInsert() || generator instanceof CompositeNestedGeneratedValueGenerator ) {
|
||||
id = persister.getIdentifier( entity, source );
|
||||
if ( id == null ) {
|
||||
throw new IdentifierGenerationException( "Identifier of entity '" + persister.getEntityName()
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Set;
|
|||
import org.hibernate.Internal;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.Remove;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
import org.hibernate.boot.model.relational.Database;
|
||||
import org.hibernate.boot.model.relational.ExportableProducer;
|
||||
import org.hibernate.boot.model.relational.QualifiedName;
|
||||
|
@ -33,6 +32,8 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
|||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.generator.BeforeExecutionGenerator;
|
||||
import org.hibernate.generator.Generator;
|
||||
import org.hibernate.id.CompositeNestedGeneratedValueGenerator;
|
||||
import org.hibernate.id.Configurable;
|
||||
import org.hibernate.id.IdentifierGenerationException;
|
||||
|
@ -47,8 +48,6 @@ import org.hibernate.metamodel.spi.EmbeddableInstantiator;
|
|||
import org.hibernate.persister.entity.DiscriminatorHelper;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.property.access.spi.Setter;
|
||||
import org.hibernate.generator.Generator;
|
||||
import org.hibernate.generator.BeforeExecutionGenerator;
|
||||
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.type.BasicType;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Indicates a problem with a TREAT usage
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TreatException extends HibernateException {
|
||||
public TreatException(String message) {
|
||||
super( message );
|
||||
}
|
||||
|
||||
public TreatException(String message, @Nullable Throwable cause) {
|
||||
super( message, cause );
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.query.sqm.tree.domain;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.query.sqm.TreatException;
|
||||
import org.hibernate.query.sqm.produce.function.FunctionArgumentException;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.query.PathException;
|
||||
|
@ -59,33 +60,33 @@ public class NonAggregatedCompositeSimplePath<T> extends SqmEntityValuedSimplePa
|
|||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedSimplePath<T, S> treatAs(Class<S> treatJavaType) throws PathException {
|
||||
throw new FunctionArgumentException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
public <S extends T> SqmTreatedEntityValuedSimplePath<T, S> treatAs(Class<S> treatJavaType) throws PathException {
|
||||
throw new TreatException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedSimplePath<T, S> treatAs(EntityDomainType<S> treatTarget) throws PathException {
|
||||
throw new FunctionArgumentException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedSimplePath<T, S> treatAs(Class<S> treatJavaType, String alias) {
|
||||
throw new FunctionArgumentException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedSimplePath<T, S> treatAs(EntityDomainType<S> treatTarget, String alias) {
|
||||
throw new FunctionArgumentException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T, S> treatAs(Class<S> treatJavaType, String alias, boolean fetch) {
|
||||
throw new FunctionArgumentException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T, S> treatAs(EntityDomainType<S> treatTarget, String alias, boolean fetch) {
|
||||
throw new FunctionArgumentException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Non-aggregate composite paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.query.sqm.NodeBuilder;
|
|||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressible;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.TreatException;
|
||||
import org.hibernate.query.sqm.produce.function.FunctionArgumentException;
|
||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
@ -104,7 +105,7 @@ public class SqmEmbeddedValuedSimplePath<T>
|
|||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T, S> treatAs(EntityDomainType<S> treatTarget) throws PathException {
|
||||
throw new FunctionArgumentException( "Embeddable paths cannot be TREAT-ed to an entity type" );
|
||||
throw new TreatException( "Embeddable paths cannot be TREAT-ed to an entity type" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ 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.query.sqm.TreatException;
|
||||
import org.hibernate.query.sqm.produce.function.FunctionArgumentException;
|
||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
@ -84,12 +85,12 @@ public class SqmFkExpression<T> extends AbstractSqmPath<T> {
|
|||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T,S> treatAs(Class<S> treatJavaType) {
|
||||
throw new FunctionArgumentException( "Fk paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Fk paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T,S> treatAs(EntityDomainType<S> treatTarget) {
|
||||
throw new FunctionArgumentException( "Fk paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Fk paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.query.spi.QueryEngine;
|
|||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressible;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.TreatException;
|
||||
import org.hibernate.query.sqm.function.SelfRenderingSqmFunction;
|
||||
import org.hibernate.query.sqm.produce.function.FunctionArgumentException;
|
||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||
|
@ -155,11 +156,11 @@ public class SqmFunctionPath<T> extends AbstractSqmPath<T> {
|
|||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T,S> treatAs(Class<S> treatJavaType) {
|
||||
throw new FunctionArgumentException( "Embeddable paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Embeddable paths cannot be TREAT-ed" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> SqmTreatedPath<T,S> treatAs(EntityDomainType<S> treatTarget) {
|
||||
throw new FunctionArgumentException( "Embeddable paths cannot be TREAT-ed" );
|
||||
throw new TreatException( "Embeddable paths cannot be TREAT-ed" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,20 +185,6 @@ public class SqmMapJoin<L, K, V>
|
|||
return treat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends V> SqmTreatedMapJoin<L, K, V, S> treatAs(Class<S> treatJavaType, String alias, boolean fetched) {
|
||||
return treatAs( nodeBuilder().getDomainModel().entity( treatJavaType ), alias, fetched );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends V> SqmTreatedMapJoin<L, K, V, S> treatAs(EntityDomainType<S> treatTarget, String alias, boolean fetched) {
|
||||
final SqmTreatedMapJoin<L, K, V, S> treat = findTreat( treatTarget, alias );
|
||||
if ( treat == null ) {
|
||||
return addTreat( new SqmTreatedMapJoin<>( this, treatTarget, alias ) );
|
||||
}
|
||||
return treat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmMapJoin<L, K, V> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmMapJoin<>(
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* 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.tree.domain;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.query.PathException;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmTreatedSimplePath<T, S extends T>
|
||||
extends SqmEntityValuedSimplePath<S>
|
||||
implements SqmSimplePath<S>, SqmTreatedPath<T,S> {
|
||||
|
||||
private final EntityDomainType<S> treatTarget;
|
||||
private final SqmPath<T> wrappedPath;
|
||||
|
||||
public SqmTreatedSimplePath(
|
||||
SqmPluralValuedSimplePath<T> wrappedPath,
|
||||
EntityDomainType<S> treatTarget,
|
||||
NodeBuilder nodeBuilder) {
|
||||
//noinspection unchecked
|
||||
super(
|
||||
wrappedPath.getNavigablePath().treatAs(
|
||||
treatTarget.getHibernateEntityName()
|
||||
),
|
||||
(SqmPathSource<S>) wrappedPath.getReferencedPathSource(),
|
||||
wrappedPath.getLhs(),
|
||||
nodeBuilder
|
||||
);
|
||||
this.treatTarget = treatTarget;
|
||||
this.wrappedPath = wrappedPath;
|
||||
}
|
||||
|
||||
public SqmTreatedSimplePath(
|
||||
SqmPath<T> wrappedPath,
|
||||
EntityDomainType<S> treatTarget,
|
||||
NodeBuilder nodeBuilder) {
|
||||
//noinspection unchecked
|
||||
super(
|
||||
wrappedPath.getNavigablePath().treatAs(
|
||||
treatTarget.getHibernateEntityName()
|
||||
),
|
||||
(SqmPathSource<S>) wrappedPath.getReferencedPathSource(),
|
||||
wrappedPath.getLhs(),
|
||||
nodeBuilder
|
||||
);
|
||||
this.treatTarget = treatTarget;
|
||||
this.wrappedPath = wrappedPath;
|
||||
}
|
||||
|
||||
private SqmTreatedSimplePath(
|
||||
NavigablePath navigablePath,
|
||||
SqmPath<T> wrappedPath,
|
||||
EntityDomainType<S> treatTarget,
|
||||
NodeBuilder nodeBuilder) {
|
||||
//noinspection unchecked
|
||||
super(
|
||||
navigablePath,
|
||||
(SqmPathSource<S>) wrappedPath.getReferencedPathSource(),
|
||||
wrappedPath.getLhs(),
|
||||
nodeBuilder
|
||||
);
|
||||
this.treatTarget = treatTarget;
|
||||
this.wrappedPath = wrappedPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmTreatedSimplePath<T, S> copy(SqmCopyContext context) {
|
||||
final SqmTreatedSimplePath<T, S> existing = context.getCopy( this );
|
||||
if ( existing != null ) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
final SqmTreatedSimplePath<T, S> path = context.registerCopy(
|
||||
this,
|
||||
new SqmTreatedSimplePath<>(
|
||||
getNavigablePath(),
|
||||
wrappedPath.copy( context ),
|
||||
getTreatTarget(),
|
||||
nodeBuilder()
|
||||
)
|
||||
);
|
||||
copyTo( path, context );
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getTreatTarget() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmPath<T> getWrappedPath() {
|
||||
return wrappedPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getNodeType() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmPathSource<S> getReferencedPathSource() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmPathSource<?> getResolvedModel() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S1 extends S> SqmTreatedEntityValuedSimplePath<S,S1> treatAs(Class<S1> treatJavaType) throws PathException {
|
||||
return super.treatAs( treatJavaType );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SqmPath<?> get(String attributeName) {
|
||||
return resolvePath( attributeName, treatTarget.getSubPathSource( attributeName ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> X accept(SemanticQueryWalker<X> walker) {
|
||||
return walker.visitTreatedPath( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHqlString(StringBuilder sb) {
|
||||
sb.append( "treat(" );
|
||||
wrappedPath.appendHqlString( sb );
|
||||
sb.append( " as " );
|
||||
sb.append( treatTarget.getName() );
|
||||
sb.append( ')' );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue