HHH-17377 - Migrate to JPA 3.2

https://hibernate.atlassian.net/browse/HHH-17377

Latest JPA 3.2 XSD changes - 9cca8e2432/api/src/main/resources/jakarta/persistence/orm_3_2.xsd
This commit is contained in:
Steve Ebersole 2023-11-06 19:51:34 -06:00
parent 3d2411a630
commit 181e32b5d7
64 changed files with 533 additions and 194 deletions

View File

@ -20,12 +20,13 @@ import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.format.FormatMapper;
import jakarta.persistence.criteria.Nulls;
/**
* The contract for building a {@link SessionFactory} given a specified set of options.
*
@ -335,7 +336,7 @@ public interface SessionFactoryBuilder {
*
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_NULL_ORDERING
*/
SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence);
SessionFactoryBuilder applyDefaultNullPrecedence(Nulls nullPrecedence);
/**
* Specify whether ordering of inserts should be enabled.

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

View File

@ -28,12 +28,13 @@ import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.format.FormatMapper;
import jakarta.persistence.criteria.Nulls;
/**
* @author Gail Badner
* @author Steve Ebersole
@ -239,7 +240,7 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
}
@Override
public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
public SessionFactoryBuilder applyDefaultNullPrecedence(Nulls nullPrecedence) {
this.optionsBuilder.applyDefaultNullPrecedence( nullPrecedence );
return this;
}

View File

@ -59,7 +59,7 @@ import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.hql.HqlTranslator;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.internal.NullPrecedenceHelper;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
@ -74,6 +74,8 @@ import org.hibernate.type.format.jackson.JacksonIntegration;
import org.hibernate.type.format.jakartajson.JakartaJsonIntegration;
import org.hibernate.type.format.jaxb.JaxbXmlFormatMapper;
import jakarta.persistence.criteria.Nulls;
import static org.hibernate.cfg.AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS;
import static org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY;
import static org.hibernate.cfg.AvailableSettings.ALLOW_UPDATE_OUTSIDE_TRANSACTION;
@ -203,7 +205,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private int defaultBatchFetchSize;
private Integer maximumFetchDepth;
private boolean subselectFetchEnabled;
private NullPrecedence defaultNullPrecedence;
private Nulls defaultNullPrecedence;
private boolean orderUpdatesEnabled;
private boolean orderInsertsEnabled;
private boolean collectionsInDefaultFetchGroupEnabled = true;
@ -388,13 +390,12 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
this.defaultNullPrecedence = (NullPrecedence) defaultNullPrecedence;
}
else if ( defaultNullPrecedence instanceof String ) {
this.defaultNullPrecedence = NullPrecedence.parse( (String) defaultNullPrecedence );
this.defaultNullPrecedence = NullPrecedenceHelper.parse( (String) defaultNullPrecedence );
}
else if ( defaultNullPrecedence != null ) {
throw new IllegalArgumentException( "Configuration property " + DEFAULT_NULL_ORDERING
+ " value [" + defaultNullPrecedence + "] is not supported" );
}
this.orderUpdatesEnabled = getBoolean( ORDER_UPDATES, configurationSettings );
this.orderInsertsEnabled = getBoolean( ORDER_INSERTS, configurationSettings );
@ -1046,7 +1047,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
}
@Override
public NullPrecedence getDefaultNullPrecedence() {
public Nulls getDefaultNullPrecedence() {
return defaultNullPrecedence;
}
@ -1462,7 +1463,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
this.subselectFetchEnabled = subselectFetchEnabled;
}
public void applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
public void applyDefaultNullPrecedence(Nulls nullPrecedence) {
this.defaultNullPrecedence = nullPrecedence;
}

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

View File

@ -211,8 +211,12 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
}
final XMLEventReader hbmReader = new HbmEventReader( staxEventReader, xmlEventFactory );
final JaxbHbmHibernateMapping hbmBindings = jaxb( hbmReader, MappingXsdSupport.INSTANCE.hbmXsd()
.getSchema(), hbmJaxbContext(), origin );
final JaxbHbmHibernateMapping hbmBindings = jaxb(
hbmReader,
MappingXsdSupport.INSTANCE.hbmXsd().getSchema(),
hbmJaxbContext(),
origin
);
if ( optionsAccess.get().transformHbmMappings() ) {
JaxbLogger.JAXB_LOGGER.tracef( "Performing on-the-fly hbm.xml -> mapping.xml transformation - %s ", origin );
@ -230,8 +234,12 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
log.debugf( "Performing JAXB binding of orm.xml document : %s", origin.toString() );
final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
final JaxbEntityMappingsImpl bindingRoot = jaxb( reader, MappingXsdSupport.latestDescriptor()
.getSchema(), mappingJaxbContext(), origin );
final JaxbEntityMappingsImpl bindingRoot = jaxb(
reader,
MappingXsdSupport.latestDescriptor().getSchema(),
mappingJaxbContext(),
origin
);
//noinspection unchecked
return new Binding<>( (X) bindingRoot, origin );
}

View File

@ -93,9 +93,10 @@ public class MappingEventReader extends EventReaderDelegate {
}
private Attribute mapAttribute(StartElement startElement, Attribute originalAttribute) {
// Here we look to see if this attribute is the JPA version attribute, and if so do 2 things:
// 1) validate its version attribute is valid
// 2) update its version attribute to the default version if not already
// Here we look to see if this attribute is the JPA version attribute, and if so do 3 things:
// 1) validate its version attribute is valid per our "latest XSD"
// 2) update its version attribute to the latest version if not already
// 3) if the latest XSD version is not in the XML list of valid versions, add it to avoid validation errors
//
// NOTE : atm this is a very simple check using just the attribute's local name
// rather than checking its qualified name. It is possibly (though unlikely)

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.internal;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.internal;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

View File

@ -20,12 +20,13 @@ import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.format.FormatMapper;
import jakarta.persistence.criteria.Nulls;
/**
* Convenience base class for custom implementors of SessionFactoryBuilder, using delegation
*
@ -187,7 +188,7 @@ public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionF
}
@Override
public T applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
public T applyDefaultNullPrecedence(Nulls nullPrecedence) {
delegate.applyDefaultNullPrecedence( nullPrecedence );
return getThis();
}

View File

@ -28,7 +28,6 @@ import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.hql.HqlTranslator;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
@ -39,6 +38,8 @@ import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.format.FormatMapper;
import jakarta.persistence.criteria.Nulls;
/**
* Convenience base class for custom implementations of {@link SessionFactoryOptions}
* using delegation.
@ -195,7 +196,7 @@ public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOp
}
@Override
public NullPrecedence getDefaultNullPrecedence() {
public Nulls getDefaultNullPrecedence() {
return delegate.getDefaultNullPrecedence();
}

View File

@ -29,7 +29,6 @@ import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.spi.QueryEngineOptions;
import org.hibernate.query.NullPrecedence;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.stat.Statistics;
@ -37,6 +36,8 @@ import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.ObjectJavaType;
import org.hibernate.type.format.FormatMapper;
import jakarta.persistence.criteria.Nulls;
/**
* Aggregator of special options used to build the {@link org.hibernate.SessionFactory}.
*
@ -149,7 +150,7 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
boolean isSubselectFetchEnabled();
NullPrecedence getDefaultNullPrecedence();
Nulls getDefaultNullPrecedence();
boolean isOrderUpdatesEnabled();

View File

@ -31,7 +31,7 @@ import org.xml.sax.SAXException;
public class LocalXsdResolver {
public static String latestJpaVerison() {
return "3.1";
return "3.2";
}
public static boolean isValidJpaVersion(String version) {
@ -42,6 +42,7 @@ public class LocalXsdResolver {
case "2.2":
case "3.0":
case "3.1":
case "3.2":
return true;
default:
return false;

View File

@ -29,6 +29,12 @@ public class MappingXsdSupport {
"http://www.hibernate.org/xsd/orm/mapping"
);
public static final XsdDescriptor _320 = LocalXsdResolver.buildXsdDescriptor(
"org/hibernate/xsd/mapping/mapping-3.2.0.xsd",
"3.2",
"http://www.hibernate.org/xsd/orm/mapping"
);
public static final XsdDescriptor jpa10 = LocalXsdResolver.buildXsdDescriptor(
"org/hibernate/jpa/orm_1_0.xsd",
"1.0",
@ -65,6 +71,12 @@ public class MappingXsdSupport {
"https://jakarta.ee/xml/ns/persistence/orm"
);
public static final XsdDescriptor jpa32 = LocalXsdResolver.buildXsdDescriptor(
"org/hibernate/jpa/orm_3_2.xsd",
"3.2",
"https://jakarta.ee/xml/ns/persistence/orm"
);
public static final XsdDescriptor hbmXml = LocalXsdResolver.buildXsdDescriptor(
"org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd",
"4.0",
@ -82,11 +94,11 @@ public class MappingXsdSupport {
}
public static XsdDescriptor latestDescriptor() {
return _310;
return _320;
}
public static XsdDescriptor latestJpaDescriptor() {
return jpa22;
return jpa32;
}
public static boolean shouldBeMappedToLatestJpaDescriptor(String uri) {
@ -102,6 +114,7 @@ public class MappingXsdSupport {
case "2.2":
case "3.0":
case "3.1":
case "3.2":
return true;
default:
return false;
@ -128,6 +141,9 @@ public class MappingXsdSupport {
case "3.1:": {
return jpa31;
}
case "3.2:": {
return jpa32;
}
default: {
throw new IllegalArgumentException( "Unrecognized JPA orm.xml XSD version : `" + version + "`" );
}

View File

@ -105,7 +105,7 @@ public interface QuerySettings {
* The default is {@code none}.
*
* @see NullPrecedence
* @see org.hibernate.boot.SessionFactoryBuilder#applyDefaultNullPrecedence(NullPrecedence)
* @see org.hibernate.boot.SessionFactoryBuilder#applyDefaultNullPrecedence(jakarta.persistence.criteria.Nulls)
*/
String DEFAULT_NULL_ORDERING = "hibernate.order_by.default_null_ordering";

View File

@ -313,7 +313,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
@Override
public void lock(Object entity, LockModeType lockMode, LockOption... options) {
delegate.lock( entity, lockMode, options );
}
@Override

View File

@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.internal.util;

View File

@ -16,7 +16,10 @@ import jakarta.persistence.criteria.Nulls;
* query result sets sorted by an {@code ORDER BY} clause.
*
* @author Lukasz Antoniak
*
* @deprecated Use Jakarta Persistence {@linkplain Nulls} instead.
*/
@Deprecated
public enum NullPrecedence {
/**
* Null precedence not specified. Relies on the RDBMS implementation.

View File

@ -24,11 +24,7 @@ import org.hibernate.Incubating;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.SortDirection;
import org.hibernate.query.sqm.FrameKind;
import org.hibernate.query.sqm.SetOperator;
import org.hibernate.query.sqm.SqmQuerySource;
import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.tree.select.SqmQueryGroup;
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.AbstractQuery;
@ -188,16 +184,15 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
<T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right);
@Override
<T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right);
default <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
return null;
}
default <T> JpaSubQuery<T> union(Subquery<? extends T> query1, Subquery<?>... queries) {
return union( false, query1, queries );
}
default <T> JpaSubQuery<T> union(boolean all, Subquery<? extends T> query1, Subquery<?>... queries) {
assert query1 instanceof SqmSelectStatement<?>;
return null;
}
<T> JpaSubQuery<T> union(boolean all, Subquery<? extends T> query1, Subquery<?>... queries);
@Override
<T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right);

View File

@ -865,7 +865,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
@Override
public JpaPredicate and(List<Predicate> restrictions) {
return null;
return criteriaBuilder.and( restrictions );
}
@Override

View File

@ -0,0 +1,93 @@
/*
* 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.internal;
import org.hibernate.AssertionFailure;
import org.hibernate.dialect.NullOrdering;
import org.hibernate.query.SortDirection;
import jakarta.persistence.criteria.Nulls;
/**
* @author Steve Ebersole
*/
public class NullPrecedenceHelper {
/**
* Is this null precedence the default for the given sort order and null ordering.
*/
public static boolean isDefaultOrdering(
Nulls precedence,
SortDirection sortOrder,
NullOrdering nullOrdering) {
switch (precedence) {
case NONE:
return true;
case FIRST:
switch ( nullOrdering ) {
case FIRST:
return true;
case LAST:
return false;
case SMALLEST:
return sortOrder == SortDirection.ASCENDING;
case GREATEST:
return sortOrder == SortDirection.DESCENDING;
default:
throw new AssertionFailure( "Unrecognized NullOrdering");
}
case LAST:
switch ( nullOrdering ) {
case LAST:
return true;
case FIRST:
return false;
case SMALLEST:
return sortOrder == SortDirection.DESCENDING;
case GREATEST:
return sortOrder == SortDirection.ASCENDING;
default:
throw new AssertionFailure("Unrecognized NullOrdering");
}
default:
throw new AssertionFailure("Unrecognized NullPrecedence");
}
}
/**
* Interprets a string representation of a NullPrecedence, returning {@code null} by default. For
* alternative default handling, see {@link #parse(String, Nulls)}
*
* @param name The String representation to interpret
*
* @return The recognized NullPrecedence, or {@code null}
*/
public static Nulls parse(String name) {
for ( Nulls value : Nulls.values() ) {
if ( value.name().equalsIgnoreCase( name ) ) {
return value;
}
}
return null;
}
/**
* Interprets a string representation of a NullPrecedence, returning the specified default if not recognized.
*
* @param name The String representation to interpret
* @param defaultValue The default value to use
*
* @return The recognized NullPrecedence, or {@code defaultValue}.
*/
public static Nulls parse(String name, Nulls defaultValue) {
final Nulls value = parse( name );
return value != null ? value : defaultValue;
}
private NullPrecedenceHelper() {
}
}

View File

@ -792,13 +792,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
@Override
public JpaCompoundSelection<Tuple> tuple(List<? extends JpaSelection<?>> selections) {
checkMultiselect( selections );
//noinspection unchecked
return new SqmJpaCompoundSelection<>(
(List<SqmSelectableNode<?>>) selections,
getTypeConfiguration().getJavaTypeRegistry().getDescriptor( Tuple.class ),
this
);
return null;
}
@Override
@ -2227,7 +2221,15 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
@Override
public SqmPredicate or(List<Predicate> restrictions) {
return null;
if ( restrictions == null || restrictions.isEmpty() ) {
return disjunction();
}
final List<SqmPredicate> predicates = new ArrayList<>( restrictions.size() );
for ( Predicate expression : restrictions ) {
predicates.add( (SqmPredicate) expression );
}
return new SqmJunctionPredicate( Predicate.BooleanOperator.OR, predicates, this );
}
@Override

View File

@ -9,12 +9,16 @@ package org.hibernate.query.sqm.tree;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmQuerySource;
import org.hibernate.query.sqm.internal.ParameterCollector;
import org.hibernate.query.sqm.internal.SqmUtil;
import org.hibernate.query.sqm.tree.expression.SqmParameter;
import org.hibernate.query.sqm.tree.expression.ValueBindJpaCriteriaParameter;
import jakarta.persistence.criteria.ParameterExpression;
import static org.hibernate.query.sqm.tree.jpa.ParameterCollector.collectParameters;
@ -82,4 +86,17 @@ public abstract class AbstractSqmStatement<T> extends AbstractSqmNode implements
public ParameterResolutions resolveParameters() {
return SqmUtil.resolveParameters( this );
}
@Override
public Set<ParameterExpression<?>> getParameters() {
// At this level, the number of parameters may still be growing as
// nodes are added to the Criteria - so we re-calculate this every
// time.
//
// for a "finalized" set of parameters, use `#resolveParameters` instead
assert getQuerySource() == SqmQuerySource.CRITERIA;
return getSqmParameters().stream()
.filter( parameterExpression -> !( parameterExpression instanceof ValueBindJpaCriteriaParameter ) )
.collect( Collectors.toSet() );
}
}

View File

@ -146,17 +146,4 @@ public class SqmDeleteStatement<T>
public <U> Subquery<U> subquery(EntityType<U> type) {
throw new UnsupportedOperationException( "DELETE query cannot be sub-query" );
}
@Override
public Set<ParameterExpression<?>> getParameters() {
// At this level, the number of parameters may still be growing as
// nodes are added to the Criteria - so we re-calculate this every
// time.
//
// for a "finalized" set of parameters, use `#resolveParameters` instead
assert getQuerySource() == SqmQuerySource.CRITERIA;
return getSqmParameters().stream()
.filter( parameterExpression -> !( parameterExpression instanceof ValueBindJpaCriteriaParameter ) )
.collect( Collectors.toSet() );
}
}

View File

@ -28,7 +28,6 @@ import org.hibernate.query.SemanticException;
import org.hibernate.query.criteria.JpaCrossJoin;
import org.hibernate.query.criteria.JpaCteCriteria;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaEntityJoin;
import org.hibernate.query.criteria.JpaPath;
import org.hibernate.query.criteria.JpaSelection;
import org.hibernate.query.hql.spi.SqmCreationState;
@ -319,7 +318,7 @@ public abstract class AbstractSqmFrom<O,T> extends AbstractSqmPath<T> implements
@Override
public <X> SqmEntityJoin<T, X> join(Class<X> targetEntityClass, SqmJoinType joinType) {
return join( nodeBuilder().getJpaMetamodel().entity( targetEntityClass ) );
return join( nodeBuilder().getJpaMetamodel().entity( targetEntityClass ), joinType );
}
@Override
@ -544,22 +543,22 @@ public abstract class AbstractSqmFrom<O,T> extends AbstractSqmPath<T> implements
}
@Override
public <R> JpaEntityJoin<T, R> join(Class<R> entityJavaType) {
public <R> SqmEntityJoin<T, R> join(Class<R> entityJavaType) {
return join( nodeBuilder().getDomainModel().entity( entityJavaType ) );
}
@Override
public <R> JpaEntityJoin<T, R> join(EntityType<R> entityType) {
public <R> SqmEntityJoin<T, R> join(EntityType<R> entityType) {
return join( entityType, JoinType.INNER );
}
@Override
public <Y> JpaEntityJoin<T, Y> join(Class<Y> entityJavaType, JoinType joinType) {
public <Y> SqmEntityJoin<T, Y> join(Class<Y> entityJavaType, JoinType joinType) {
return join( nodeBuilder().getDomainModel().entity( entityJavaType ), joinType );
}
@Override
public <Y> JpaEntityJoin<T, Y> join(EntityType<Y> entity, JoinType joinType) {
public <Y> SqmEntityJoin<T, Y> join(EntityType<Y> entity, JoinType joinType) {
//noinspection unchecked
final SqmEntityJoin<T,Y> join = new SqmEntityJoin<>( entity, null, joinType, (SqmRoot<T>) findRoot() );
addSqmJoin( join );

View File

@ -13,6 +13,7 @@ import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmEntityJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.query.sqm.tree.from.SqmJoin;
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
@ -136,4 +137,14 @@ public abstract class AbstractSqmJoin<L, R> extends AbstractSqmFrom<L, R> implem
applyRestriction( nodeBuilder().wrap( restrictions ) );
return this;
}
@Override
public <X> SqmEntityJoin<R, X> join(Class<X> targetEntityClass) {
return super.join( targetEntityClass, joinType );
}
@Override
public <X> SqmEntityJoin<R, X> join(Class<X> targetEntityClass, SqmJoinType joinType) {
return super.join( targetEntityClass, joinType );
}
}

View File

@ -19,7 +19,7 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedBagJoin<O, T> extends SqmBagJoin<O, T> implements SqmCorrelation<O, T> {
public class SqmCorrelatedBagJoin<O, T> extends SqmBagJoin<O, T> implements SqmCorrelatedJoin<O, T> {
private final SqmCorrelatedRootJoin<O> correlatedRootJoin;
private final SqmBagJoin<O, T> correlationParent;

View File

@ -18,7 +18,7 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedEntityJoin<L,R> extends SqmEntityJoin<L,R> implements SqmCorrelation<L, R> {
public class SqmCorrelatedEntityJoin<L,R> extends SqmEntityJoin<L,R> implements SqmCorrelatedSingularValuedJoin<L, R> {
private final SqmCorrelatedRootJoin<L> correlatedRootJoin;
private final SqmEntityJoin<L,R> correlationParent;
@ -98,6 +98,11 @@ public class SqmCorrelatedEntityJoin<L,R> extends SqmEntityJoin<L,R> implements
return correlatedRootJoin;
}
@Override
public SqmCorrelatedEntityJoin<L,R> createCorrelation() {
return new SqmCorrelatedEntityJoin<>( this );
}
@Override
public SqmCorrelatedEntityJoin<L,R> makeCopy(SqmCreationProcessingState creationProcessingState) {
final SqmPathRegistry pathRegistry = creationProcessingState.getPathRegistry();

View File

@ -0,0 +1,15 @@
/*
* 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.query.sqm.tree.from.SqmJoin;
/**
* @author Steve Ebersole
*/
public interface SqmCorrelatedJoin<L,R> extends SqmCorrelation<L, R>, SqmJoin<L, R> {
}

View File

@ -19,7 +19,7 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedListJoin<O, T> extends SqmListJoin<O, T> implements SqmCorrelation<O, T> {
public class SqmCorrelatedListJoin<O, T> extends SqmListJoin<O, T> implements SqmCorrelatedJoin<O, T> {
private final SqmCorrelatedRootJoin<O> correlatedRootJoin;
private final SqmListJoin<O, T> correlationParent;

View File

@ -19,7 +19,7 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedMapJoin<L,K,V> extends SqmMapJoin<L,K,V> implements SqmCorrelation<L,V> {
public class SqmCorrelatedMapJoin<L,K,V> extends SqmMapJoin<L,K,V> implements SqmCorrelatedJoin<L,V> {
private final SqmCorrelatedRootJoin<L> correlatedRootJoin;
private final SqmMapJoin<L, K, V> correlationParent;

View File

@ -9,13 +9,12 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedPluralPartJoin<O, T> extends SqmPluralPartJoin<O, T> implements SqmCorrelation<O, T> {
public class SqmCorrelatedPluralPartJoin<O, T> extends SqmPluralPartJoin<O, T> implements SqmCorrelatedJoin<O, T> {
private final SqmCorrelatedRootJoin<O> correlatedRootJoin;
private final SqmPluralPartJoin<O, T> correlationParent;

View File

@ -19,7 +19,7 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedSetJoin<O, T> extends SqmSetJoin<O, T> implements SqmCorrelation<O, T> {
public class SqmCorrelatedSetJoin<O, T> extends SqmSetJoin<O, T> implements SqmCorrelatedJoin<O, T> {
private final SqmCorrelatedRootJoin<O> correlatedRootJoin;
private final SqmSetJoin<O, T> correlationParent;

View File

@ -19,7 +19,7 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* @author Christian Beikov
*/
public class SqmCorrelatedSingularJoin<O, T> extends SqmSingularJoin<O, T> implements SqmCorrelation<O, T> {
public class SqmCorrelatedSingularJoin<O, T> extends SqmSingularJoin<O, T> implements SqmCorrelatedSingularValuedJoin<O, T> {
private final SqmCorrelatedRootJoin<O> correlatedRootJoin;
private final SqmSingularJoin<O, T> correlationParent;

View File

@ -0,0 +1,13 @@
/*
* 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;
/**
* @author Steve Ebersole
*/
public interface SqmCorrelatedSingularValuedJoin<L,R> extends SqmSingularValuedJoin<L, R>, SqmCorrelatedJoin<L, R> {
}

View File

@ -29,7 +29,7 @@ import org.hibernate.spi.NavigablePath;
/**
* @author Steve Ebersole
*/
public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> implements SqmSingularValuedJoin<O,T> {
public SqmSingularJoin(
SqmFrom<?,O> lhs,
SingularPersistentAttribute<O, T> joinedNavigable,

View File

@ -0,0 +1,16 @@
/*
* 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.query.sqm.tree.from.SqmJoin;
/**
* @author Steve Ebersole
*/
public interface SqmSingularValuedJoin<L,R> extends SqmJoin<L, R> {
SqmCorrelatedSingularValuedJoin<L,R> createCorrelation();
}

View File

@ -17,7 +17,7 @@ import org.hibernate.spi.NavigablePath;
/**
* @author Steve Ebersole
*/
public class SqmTreatedRoot<T, S extends T> extends SqmRoot<S> implements SqmTreatedPath<T,S> {
public class SqmTreatedRoot<T, S extends T> extends SqmRoot<S> implements SqmTreatedFrom<S,T,S> {
private final SqmRoot<T> wrappedPath;
private final EntityDomainType<S> treatTarget;
@ -53,7 +53,7 @@ public class SqmTreatedRoot<T, S extends T> extends SqmRoot<S> implements SqmTre
}
@Override
public SqmRoot<S> copy(SqmCopyContext context) {
public SqmTreatedRoot<T,S> copy(SqmCopyContext context) {
final SqmTreatedRoot<T, S> existing = context.getCopy( this );
if ( existing != null ) {
return existing;

View File

@ -20,6 +20,7 @@ import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.AbstractSqmJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedEntityJoin;
import org.hibernate.query.sqm.tree.domain.SqmSingularValuedJoin;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.domain.SqmTreatedEntityJoin;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
@ -33,7 +34,7 @@ import jakarta.persistence.metamodel.EntityType;
/**
* @author Steve Ebersole
*/
public class SqmEntityJoin<L,R> extends AbstractSqmJoin<L,R> implements JpaEntityJoin<L,R> {
public class SqmEntityJoin<L,R> extends AbstractSqmJoin<L,R> implements SqmSingularValuedJoin<L,R>, JpaEntityJoin<L,R> {
private final SqmRoot<L> sqmRoot;
public SqmEntityJoin(
@ -213,4 +214,6 @@ public class SqmEntityJoin<L,R> extends AbstractSqmJoin<L,R> implements JpaEntit
pathRegistry.findFromByPath( getRoot().getNavigablePath() )
);
}
}

View File

@ -17,6 +17,7 @@ import jakarta.persistence.metamodel.SetAttribute;
import jakarta.persistence.metamodel.SingularAttribute;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.criteria.JpaEntityJoin;
import org.hibernate.query.criteria.JpaFrom;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.SqmCopyContext;
@ -92,6 +93,12 @@ public interface SqmFrom<L, R> extends SqmVisitableNode, SqmPath<R>, JpaFrom<L,
@Override
SqmFrom<L, R> getCorrelationParent();
@Override
<Y> SqmEntityJoin<R, Y> join(Class<Y> entityClass);
@Override
<Y> SqmEntityJoin<R, Y> join(Class<Y> entityClass, JoinType joinType);
@Override
<A> SqmSingularJoin<R, A> join(SingularAttribute<? super R, A> attribute);

View File

@ -9,13 +9,29 @@ package org.hibernate.query.sqm.tree.from;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.JoinType;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Subquery;
import jakarta.persistence.metamodel.CollectionAttribute;
import jakarta.persistence.metamodel.EntityType;
import jakarta.persistence.metamodel.ListAttribute;
import jakarta.persistence.metamodel.MapAttribute;
import jakarta.persistence.metamodel.SetAttribute;
import jakarta.persistence.metamodel.SingularAttribute;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.criteria.JpaCrossJoin;
import org.hibernate.query.criteria.JpaCteCriteria;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaEntityJoin;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaJoin;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmBagJoin;
import org.hibernate.query.sqm.tree.domain.SqmListJoin;
import org.hibernate.query.sqm.tree.domain.SqmMapJoin;
import org.hibernate.query.sqm.tree.domain.SqmSetJoin;
import org.hibernate.query.sqm.tree.domain.SqmSingularJoin;
import org.hibernate.query.sqm.tree.domain.SqmTreatedJoin;
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
@ -110,4 +126,102 @@ public interface SqmJoin<L, R> extends SqmFrom<L, R>, JpaJoin<L,R> {
) );
return this;
}
@Override
default <X> JpaEntityJoin<R, X> join(Class<X> entityJavaType, SqmJoinType joinType) {
return SqmFrom.super.join( entityJavaType, joinType );
}
@Override
<Y> JpaJoin<R, Y> join(EntityType<Y> entity);
@Override
<Y> JpaJoin<R, Y> join(EntityType<Y> entity, JoinType joinType);
@Override
<X> JpaEntityJoin<R, X> join(EntityDomainType<X> entity);
@Override
<X> JpaEntityJoin<R, X> join(EntityDomainType<X> entity, SqmJoinType joinType);
@Override
<X> JpaDerivedJoin<X> join(Subquery<X> subquery);
@Override
<X> JpaDerivedJoin<X> join(Subquery<X> subquery, SqmJoinType joinType);
@Override
<X> JpaDerivedJoin<X> joinLateral(Subquery<X> subquery);
@Override
<X> JpaDerivedJoin<X> joinLateral(Subquery<X> subquery, SqmJoinType joinType);
@Override
<X> JpaDerivedJoin<X> join(Subquery<X> subquery, SqmJoinType joinType, boolean lateral);
@Override
<X> JpaJoin<?, X> join(JpaCteCriteria<X> cte);
@Override
<X> JpaJoin<?, X> join(JpaCteCriteria<X> cte, SqmJoinType joinType);
@Override
<X> JpaCrossJoin<X> crossJoin(Class<X> entityJavaType);
@Override
<X> JpaCrossJoin<X> crossJoin(EntityDomainType<X> entity);
@Override
<A> SqmSingularJoin<R, A> join(SingularAttribute<? super R, A> attribute);
@Override
<A> SqmSingularJoin<R, A> join(SingularAttribute<? super R, A> attribute, JoinType jt);
@Override
<E> SqmBagJoin<R, E> join(CollectionAttribute<? super R, E> attribute);
@Override
<E> SqmBagJoin<R, E> join(CollectionAttribute<? super R, E> attribute, JoinType jt);
@Override
<E> SqmSetJoin<R, E> join(SetAttribute<? super R, E> set);
@Override
<E> SqmSetJoin<R, E> join(SetAttribute<? super R, E> set, JoinType jt);
@Override
<E> SqmListJoin<R, E> join(ListAttribute<? super R, E> list);
@Override
<E> SqmListJoin<R, E> join(ListAttribute<? super R, E> list, JoinType jt);
@Override
<K, V> SqmMapJoin<R, K, V> join(MapAttribute<? super R, K, V> map);
@Override
<K, V> SqmMapJoin<R, K, V> join(MapAttribute<? super R, K, V> map, JoinType jt);
@Override
<X, Y> SqmBagJoin<X, Y> joinCollection(String attributeName);
@Override
<X, Y> SqmBagJoin<X, Y> joinCollection(String attributeName, JoinType jt);
@Override
<X, Y> SqmSetJoin<X, Y> joinSet(String attributeName);
@Override
<X, Y> SqmSetJoin<X, Y> joinSet(String attributeName, JoinType jt);
@Override
<X, Y> SqmListJoin<X, Y> joinList(String attributeName);
@Override
<X, Y> SqmListJoin<X, Y> joinList(String attributeName, JoinType jt);
@Override
<X, K, V> SqmMapJoin<X, K, V> joinMap(String attributeName);
@Override
<X, K, V> SqmMapJoin<X, K, V> joinMap(String attributeName, JoinType jt);
}

View File

@ -25,12 +25,12 @@ public class SqmSortSpecification implements JpaOrder {
private final SqmExpression sortExpression;
private final SortDirection sortOrder;
private final boolean ignoreCase;
private NullPrecedence nullPrecedence;
private Nulls nullPrecedence;
public SqmSortSpecification(
@SuppressWarnings("rawtypes") SqmExpression sortExpression,
SortDirection sortOrder,
NullPrecedence nullPrecedence) {
Nulls nullPrecedence) {
this( sortExpression, sortOrder, nullPrecedence, false );
}
@ -48,14 +48,25 @@ public class SqmSortSpecification implements JpaOrder {
this.ignoreCase = ignoreCase;
}
/**
* @deprecated Use {@link SqmSortSpecification#SqmSortSpecification(SqmExpression, SortDirection, Nulls)} instead
*/
@Deprecated
public SqmSortSpecification(
@SuppressWarnings("rawtypes") SqmExpression sortExpression,
SortDirection sortOrder,
NullPrecedence nullPrecedence) {
this( sortExpression, sortOrder, nullPrecedence.getJpaValue() );
}
@SuppressWarnings("rawtypes")
public SqmSortSpecification(SqmExpression sortExpression) {
this( sortExpression, SortDirection.ASCENDING, NullPrecedence.NONE );
this( sortExpression, SortDirection.ASCENDING, Nulls.NONE );
}
@SuppressWarnings("rawtypes")
public SqmSortSpecification(SqmExpression sortExpression, SortDirection sortOrder) {
this( sortExpression, sortOrder, NullPrecedence.NONE );
this( sortExpression, sortOrder, Nulls.NONE );
}
public SqmSortSpecification copy(SqmCopyContext context) {
@ -81,13 +92,13 @@ public class SqmSortSpecification implements JpaOrder {
@Override
public JpaOrder nullPrecedence(Nulls nullPrecedence) {
this.nullPrecedence = NullPrecedence.fromJpaValue( nullPrecedence );
this.nullPrecedence = nullPrecedence;
return this;
}
@Override
public Nulls getNullPrecedence() {
return nullPrecedence.getJpaValue();
return nullPrecedence;
}
@Override
@ -111,7 +122,7 @@ public class SqmSortSpecification implements JpaOrder {
if ( sortOrder == SortDirection.DESCENDING ) {
sb.append( " desc" );
if ( nullPrecedence != null ) {
if ( nullPrecedence == NullPrecedence.FIRST ) {
if ( nullPrecedence == Nulls.FIRST ) {
sb.append( " nulls first" );
}
else {
@ -121,7 +132,7 @@ public class SqmSortSpecification implements JpaOrder {
}
else if ( nullPrecedence != null ) {
sb.append( " asc" );
if ( nullPrecedence == NullPrecedence.FIRST ) {
if ( nullPrecedence == Nulls.FIRST ) {
sb.append( " nulls first" );
}
else {

View File

@ -36,16 +36,18 @@ import org.hibernate.query.sqm.tree.domain.SqmBagJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedBagJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedCrossJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedEntityJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedListJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedMapJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedRoot;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedSetJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedSingularJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedSingularValuedJoin;
import org.hibernate.query.sqm.tree.domain.SqmCorrelation;
import org.hibernate.query.sqm.tree.domain.SqmListJoin;
import org.hibernate.query.sqm.tree.domain.SqmMapJoin;
import org.hibernate.query.sqm.tree.domain.SqmSetJoin;
import org.hibernate.query.sqm.tree.domain.SqmSingularJoin;
import org.hibernate.query.sqm.tree.domain.SqmSingularValuedJoin;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmCrossJoin;
@ -477,7 +479,7 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
}
@Override
public <X, Y> SqmAttributeJoin<X, Y> correlate(Join<X, Y> join) {
public <X, Y> SqmCorrelatedJoin<X, Y> correlate(Join<X, Y> join) {
if ( join instanceof PluralJoin<?, ?, ?> ) {
final PluralJoin<?, ?, ?> pluralJoin = (PluralJoin<?, ?, ?>) join;
switch ( pluralJoin.getModel().getCollectionType() ) {
@ -491,41 +493,41 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
return correlate( (MapJoin<X, ?, Y>) join );
}
}
final SqmCorrelatedSingularJoin<X, Y> correlated = ( (SqmSingularJoin<X, Y>) join ).createCorrelation();
final SqmCorrelatedSingularValuedJoin<X, Y> correlated = ( (SqmSingularValuedJoin<X, Y>) join ).createCorrelation();
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
return correlated;
}
@Override
public <X, Y> SqmBagJoin<X, Y> correlate(CollectionJoin<X, Y> parentCollection) {
public <X, Y> SqmCorrelatedBagJoin<X, Y> correlate(CollectionJoin<X, Y> parentCollection) {
final SqmCorrelatedBagJoin<X, Y> correlated = ( (SqmBagJoin<X, Y>) parentCollection ).createCorrelation();
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
return correlated;
}
@Override
public <X, Y> SqmSetJoin<X, Y> correlate(SetJoin<X, Y> parentSet) {
public <X, Y> SqmCorrelatedSetJoin<X, Y> correlate(SetJoin<X, Y> parentSet) {
final SqmCorrelatedSetJoin<X, Y> correlated = ( (SqmSetJoin<X, Y>) parentSet ).createCorrelation();
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
return correlated;
}
@Override
public <X, Y> SqmListJoin<X, Y> correlate(ListJoin<X, Y> parentList) {
public <X, Y> SqmCorrelatedListJoin<X, Y> correlate(ListJoin<X, Y> parentList) {
final SqmCorrelatedListJoin<X, Y> correlated = ( (SqmListJoin<X, Y>) parentList ).createCorrelation();
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
return correlated;
}
@Override
public <X, K, V> SqmMapJoin<X, K, V> correlate(MapJoin<X, K, V> parentMap) {
public <X, K, V> SqmCorrelatedMapJoin<X, K, V> correlate(MapJoin<X, K, V> parentMap) {
final SqmCorrelatedMapJoin<X, K, V> correlated = ( (SqmMapJoin<X, K, V>) parentMap ).createCorrelation();
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
return correlated;
}
@Override
public <X> SqmCrossJoin<X> correlate(JpaCrossJoin<X> parentCrossJoin) {
public <X> SqmCorrelatedCrossJoin<X> correlate(JpaCrossJoin<X> parentCrossJoin) {
final SqmCorrelatedCrossJoin<X> correlated =
((SqmCrossJoin<X>) parentCrossJoin).createCorrelation();
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );

View File

@ -264,11 +264,6 @@ public class SqmUpdateStatement<T>
return new SqmSubQuery<>( this, type, nodeBuilder() );
}
@Override
public Set<ParameterExpression<?>> getParameters() {
return null;
}
public <Y> void applyAssignment(SqmPath<Y> targetPath, SqmExpression<? extends Y> value) {
applyAssignment( new SqmAssignment<>( targetPath, value ) );
}

View File

@ -28,8 +28,8 @@ import org.hibernate.Internal;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.QueryException;
import org.hibernate.dialect.DmlTargetColumnQualifierSupport;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DmlTargetColumnQualifierSupport;
import org.hibernate.dialect.RowLockStrategy;
import org.hibernate.dialect.SelectItemReferenceStrategy;
import org.hibernate.engine.jdbc.Size;
@ -61,8 +61,10 @@ import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.query.IllegalQueryOperationException;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.ReturnableType;
import org.hibernate.query.SortDirection;
import org.hibernate.query.results.TableGroupImpl;
import org.hibernate.query.spi.Limit;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.sqm.BinaryArithmeticOperator;
@ -71,7 +73,6 @@ import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.query.sqm.FrameExclusion;
import org.hibernate.query.sqm.FrameKind;
import org.hibernate.query.sqm.FrameMode;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.SetOperator;
import org.hibernate.query.sqm.UnaryArithmeticOperator;
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
@ -227,6 +228,8 @@ import org.hibernate.type.descriptor.sql.DdlType;
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration;
import jakarta.persistence.criteria.Nulls;
import static org.hibernate.persister.entity.DiscriminatorHelper.jdbcLiteral;
import static org.hibernate.query.sqm.BinaryArithmeticOperator.DIVIDE_PORTABLE;
import static org.hibernate.query.sqm.TemporalUnit.NANOSECOND;
@ -2585,12 +2588,12 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
appendSql( searchBySpecification.getCteColumn().getColumnExpression() );
final SortDirection sortOrder = searchBySpecification.getSortOrder();
if ( sortOrder != null ) {
NullPrecedence nullPrecedence = searchBySpecification.getNullPrecedence();
if ( nullPrecedence == null || nullPrecedence == NullPrecedence.NONE ) {
Nulls nullPrecedence = searchBySpecification.getNullPrecedence();
if ( nullPrecedence == null || nullPrecedence == Nulls.NONE ) {
nullPrecedence = sessionFactory.getSessionFactoryOptions().getDefaultNullPrecedence();
}
final boolean renderNullPrecedence = nullPrecedence != null &&
!nullPrecedence.isDefaultOrdering( sortOrder, dialect.getNullOrdering() );
final boolean renderNullPrecedence = nullPrecedence != null
&& !NullPrecedenceHelper.isDefaultOrdering( nullPrecedence, sortOrder, dialect.getNullOrdering() );
if ( sortOrder == SortDirection.DESCENDING ) {
appendSql( " desc" );
}
@ -2598,7 +2601,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
appendSql( " asc" );
}
if ( renderNullPrecedence ) {
if ( searchBySpecification.getNullPrecedence() == NullPrecedence.FIRST ) {
if ( searchBySpecification.getNullPrecedence() == Nulls.FIRST ) {
appendSql( " nulls first" );
}
else {
@ -2722,7 +2725,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2754,7 +2757,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2781,7 +2784,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2803,7 +2806,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2864,7 +2867,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2902,7 +2905,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2941,7 +2944,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -2980,7 +2983,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( searchBySpecification.getSortOrder() == SortDirection.DESCENDING ) {
throw new IllegalArgumentException( "Can't emulate search clause for descending search specifications" );
}
if ( searchBySpecification.getNullPrecedence() != NullPrecedence.NONE ) {
if ( searchBySpecification.getNullPrecedence() != Nulls.NONE ) {
throw new IllegalArgumentException( "Can't emulate search clause for search specifications with explicit null precedence" );
}
final int selectionIndex = currentCteStatement.getCteTable()
@ -4380,7 +4383,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
@Override
public void visitSortSpecification(SortSpecification sortSpecification) {
final Expression sortExpression = sortSpecification.getSortExpression();
final NullPrecedence nullPrecedence = sortSpecification.getHibernateNullPrecedence();
final Nulls nullPrecedence = sortSpecification.getNullPrecedence();
final SortDirection sortOrder = sortSpecification.getSortOrder();
final boolean ignoreCase = sortSpecification.isIgnoreCase();
final SqlTuple sqlTuple = SqlTupleContainer.getSqlTuple( sortExpression );
@ -4400,13 +4403,13 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
protected void visitSortSpecification(
Expression sortExpression,
SortDirection sortOrder,
NullPrecedence nullPrecedence,
Nulls nullPrecedence,
boolean ignoreCase) {
if ( nullPrecedence == null || nullPrecedence == NullPrecedence.NONE ) {
if ( nullPrecedence == null || nullPrecedence == Nulls.NONE ) {
nullPrecedence = sessionFactory.getSessionFactoryOptions().getDefaultNullPrecedence();
}
final boolean renderNullPrecedence = nullPrecedence != null &&
!nullPrecedence.isDefaultOrdering( sortOrder, dialect.getNullOrdering() );
final boolean renderNullPrecedence = nullPrecedence != null
&& !NullPrecedenceHelper.isDefaultOrdering( nullPrecedence, sortOrder, dialect.getNullOrdering() );
final boolean supportsNullPrecedence = renderNullPrecedence && supportsNullPrecedence();
if ( renderNullPrecedence && !supportsNullPrecedence ) {
emulateSortSpecificationNullPrecedence( sortExpression, nullPrecedence );
@ -4423,7 +4426,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( renderNullPrecedence && supportsNullPrecedence ) {
appendSql( " nulls " );
appendSql( nullPrecedence == NullPrecedence.LAST ? "last" : "first" );
appendSql( nullPrecedence == Nulls.LAST ? "last" : "first" );
}
}
@ -4443,18 +4446,30 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( ignoreCase ) {
appendSql( CLOSE_PARENTHESIS );
}
if ( sortOrder == SortDirection.DESCENDING ) {
appendSql( " desc" );
}
else if ( sortOrder == SortDirection.ASCENDING && renderNullPrecedence && supportsNullPrecedence ) {
appendSql( " asc" );
}
if ( renderNullPrecedence && supportsNullPrecedence ) {
appendSql( " nulls " );
appendSql( nullPrecedence == Nulls.LAST ? "last" : "first" );
}
}
protected boolean supportsNullPrecedence() {
return dialect.supportsNullPrecedence();
}
protected void emulateSortSpecificationNullPrecedence(Expression sortExpression, NullPrecedence nullPrecedence) {
protected void emulateSortSpecificationNullPrecedence(Expression sortExpression, Nulls nullPrecedence) {
// TODO: generate "virtual" select items and use them here positionally
appendSql( "case when (" );
resolveAliasedExpression( sortExpression ).accept( this );
appendSql( ") is null then " );
if ( nullPrecedence == NullPrecedence.FIRST ) {
if ( nullPrecedence == Nulls.FIRST ) {
appendSql( "0 else 1" );
}
else {
@ -6735,28 +6750,28 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
}
private boolean isNullsFirst(SortSpecification sortSpecification) {
NullPrecedence nullPrecedence = sortSpecification.getHibernateNullPrecedence();
if ( nullPrecedence == null || nullPrecedence == NullPrecedence.NONE ) {
Nulls nullPrecedence = sortSpecification.getNullPrecedence();
if ( nullPrecedence == null || nullPrecedence == Nulls.NONE ) {
switch ( dialect.getNullOrdering() ) {
case FIRST:
nullPrecedence = NullPrecedence.FIRST;
nullPrecedence = Nulls.FIRST;
break;
case LAST:
nullPrecedence = NullPrecedence.LAST;
nullPrecedence = Nulls.LAST;
break;
case SMALLEST:
nullPrecedence = sortSpecification.getSortOrder() == SortDirection.ASCENDING
? NullPrecedence.FIRST
: NullPrecedence.LAST;
? Nulls.FIRST
: Nulls.LAST;
break;
case GREATEST:
nullPrecedence = sortSpecification.getSortOrder() == SortDirection.DESCENDING
? NullPrecedence.FIRST
: NullPrecedence.LAST;
? Nulls.FIRST
: Nulls.LAST;
break;
}
}
return nullPrecedence == NullPrecedence.FIRST;
return nullPrecedence == Nulls.FIRST;
}
private int getSortSelectionIndex(QuerySpec querySpec, SortSpecification sortSpecification) {

View File

@ -9,20 +9,30 @@ package org.hibernate.sql.ast.tree.cte;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.SortDirection;
import jakarta.persistence.criteria.Nulls;
/**
* @author Christian Beikov
*/
public class SearchClauseSpecification {
private final CteColumn cteColumn;
private final SortDirection sortOrder;
private final NullPrecedence nullPrecedence;
private final Nulls nullPrecedence;
public SearchClauseSpecification(CteColumn cteColumn, SortDirection sortOrder, NullPrecedence nullPrecedence) {
public SearchClauseSpecification(CteColumn cteColumn, SortDirection sortOrder, Nulls nullPrecedence) {
this.cteColumn = cteColumn;
this.sortOrder = sortOrder;
this.nullPrecedence = nullPrecedence;
}
/**
* @deprecated Use {@link SearchClauseSpecification#SearchClauseSpecification(CteColumn,SortDirection,Nulls)} instead
*/
@Deprecated
public SearchClauseSpecification(CteColumn cteColumn, SortDirection sortOrder, NullPrecedence nullPrecedence) {
this( cteColumn, sortOrder, nullPrecedence.getJpaValue() );
}
public CteColumn getCteColumn() {
return cteColumn;
}
@ -31,7 +41,7 @@ public class SearchClauseSpecification {
return sortOrder;
}
public NullPrecedence getNullPrecedence() {
public Nulls getNullPrecedence() {
return nullPrecedence;
}
}

View File

@ -20,18 +20,18 @@ import jakarta.persistence.criteria.Nulls;
public class SortSpecification implements SqlAstNode {
private final Expression sortExpression;
private final SortDirection sortOrder;
private final NullPrecedence nullPrecedence;
private final Nulls nullPrecedence;
private final boolean ignoreCase;
public SortSpecification(Expression sortExpression, SortDirection sortOrder) {
this( sortExpression, sortOrder, NullPrecedence.NONE );
this( sortExpression, sortOrder, Nulls.NONE, false );
}
public SortSpecification(Expression sortExpression, SortDirection sortOrder, NullPrecedence nullPrecedence) {
this(sortExpression, sortOrder, nullPrecedence, false);
this( sortExpression, sortOrder, nullPrecedence.getJpaValue(), false );
}
public SortSpecification(Expression sortExpression, SortDirection sortOrder, NullPrecedence nullPrecedence, boolean ignoreCase) {
public SortSpecification(Expression sortExpression, SortDirection sortOrder, Nulls nullPrecedence, boolean ignoreCase) {
assert sortExpression != null;
assert sortOrder != null;
assert nullPrecedence != null;
@ -41,10 +41,6 @@ public class SortSpecification implements SqlAstNode {
this.ignoreCase = ignoreCase;
}
public SortSpecification(Expression sortExpression, SortDirection sortOrder, Nulls nullPrecedence) {
this( sortExpression,sortOrder, NullPrecedence.fromJpaValue( nullPrecedence ) );
}
public Expression getSortExpression() {
return sortExpression;
}
@ -53,12 +49,8 @@ public class SortSpecification implements SqlAstNode {
return sortOrder;
}
public NullPrecedence getHibernateNullPrecedence() {
return nullPrecedence;
}
public Nulls getNullPrecedence() {
return nullPrecedence.getJpaValue();
return nullPrecedence;
}
public boolean isIgnoreCase() {

View File

@ -7,11 +7,11 @@
-->
<!-- Jakarta Persistence API object/relational mapping file schema -->
<xsd:schema targetNamespace="https://jakarta.ee/xml/ns/persistence/orm"
xmlns:orm="https://jakarta.ee/xml/ns/persistence/orm"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.hibernate.org/xsd/orm/mapping"
xmlns:orm="http://www.hibernate.org/xsd/orm/mapping"
targetNamespace="http://www.hibernate.org/xsd/orm/mapping"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="3.2">
<xsd:annotation>
<xsd:documentation><![CDATA[
@ -20,7 +20,7 @@
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.1">
version="3.2">
...
</entity-mappings>
]]></xsd:documentation>

View File

@ -13,7 +13,7 @@ import org.hibernate.query.sqm.tree.select.SqmSortSpecification;
import org.hibernate.testing.TestForIssue;
import org.junit.Test;
import static org.hibernate.query.NullPrecedence.FIRST;
import static jakarta.persistence.criteria.Nulls.FIRST;
import static org.hibernate.query.SortDirection.ASCENDING;
import static org.hibernate.query.SortDirection.DESCENDING;
import static org.junit.Assert.assertEquals;

View File

@ -6,16 +6,19 @@
~ 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.
-->
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping" version="3.1">
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping" version="3.2">
<package>org.hibernate.orm.test.boot.jaxb.mapping</package>
<entity class="HibernateOrmSpecificAttributesMappingTest$MyEntity">
<attributes>
<!-- 1 == CHAR -->
<id name="id" jdbc-type-code="1">
<uuid-generator style="time"/>
<id name="id">
<uuid-generator style="TIME"/>
<jdbc-type-code>1</jdbc-type-code>
</id>
<!-- 2005 == CLOB -->
<basic name="name" jdbc-type-code="2005"/>
<basic name="name">
<jdbc-type-code>2005</jdbc-type-code>
</basic>
<basic name="tags">
<type value="org.hibernate.orm.test.boot.jaxb.mapping.HibernateOrmSpecificAttributesMappingTest$DelimitedStringsJavaType"/>
</basic>