Rename JPA copy compliance setting to `hibernate.criteria.copy_tree`

This commit is contained in:
Christian Beikov 2022-02-10 17:19:31 +01:00
parent 07f3d6727f
commit 5bfbc466eb
25 changed files with 98 additions and 127 deletions

View File

@ -79,17 +79,6 @@ Traditionally, Hibernate has considered the names locally scoped.
If enabled, the names used by `@TableGenerator` and `@SequenceGenerator` will be considered global so configuring two different generators
with the same name will cause a `java.lang.IllegalArgumentException` to be thrown at boot time.
`*hibernate.jpa.compliance.criteria_copy*` (e.g. `true` (default value) or `false` )::
The Jakarta Persistence spec says that mutations done to `CriteriaQuery`, `CriteriaUpdate` and `CriteriaDelete`
after such objects were used to create a `jakarta.persistence.Query` may not affect that query.
This requirement makes it necessary to copy these objects because the APIs allow mutations.
+
If disabled, it is assumed that users do not mutate the criteria query afterwards
and due to that, no copy will be created, which will improve performance.
+
By default, no copies are created to not hurt performance. When enabled,
criteria query objects are copied, as required by the JPA specification.
[[configurations-database-connection]]
=== Database connection properties
@ -509,6 +498,19 @@ The {@link org.hibernate.query.criteria.ValueHandlingMode#INLINE} mode will inli
The default value is {@link org.hibernate.query.criteria.ValueHandlingMode#BIND}.
Valid options are defined by the `org.hibernate.query.criteria.ValueHandlingMode` enum.
`*hibernate.criteria.copy_tree*` (e.g. `true` or `false` (default value) )::
The Jakarta Persistence spec says that mutations done to `CriteriaQuery`, `CriteriaUpdate` and `CriteriaDelete`
after such objects were used to create a `jakarta.persistence.Query` may not affect that query.
This requirement makes it necessary to copy these objects because the APIs allow mutations.
+
If disabled, it is assumed that users do not mutate the criteria query afterwards
and due to that, no copy will be created, which will improve performance.
+
When bootstrapping Hibernate through the native bootstrap APIs this setting is disabled
i.e. no copies are created to not hurt performance.
When bootstrapping Hibernate through the JPA SPI this setting is enabled.
When enabled, criteria query objects are copied, as required by the Jakarta Persistence specification.
`*hibernate.query.fail_on_pagination_over_collection_fetch*` (e.g. `true` or `false` (default value))::
Raises an exception when in-memory pagination over collection fetch is about to be performed.
+

View File

@ -238,6 +238,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private boolean connectionProviderDisablesAutoCommit;
private TimeZone jdbcTimeZone;
private ValueHandlingMode criteriaValueHandlingMode;
private boolean criteriaCopyTreeEnabled;
private ImmutableEntityUpdateQueryHandlingMode immutableEntityUpdateQueryHandlingMode;
// These two settings cannot be modified from the builder,
// in order to maintain consistency.
@ -534,6 +535,11 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
this.criteriaValueHandlingMode = ValueHandlingMode.interpret(
configurationSettings.get( CRITERIA_VALUE_HANDLING_MODE )
);
this.criteriaCopyTreeEnabled = ConfigurationHelper.getBoolean(
AvailableSettings.CRITERIA_COPY_TREE,
configurationSettings,
jpaBootstrap
);
// added the boolean parameter in case we want to define some form of "all" as discussed
this.jpaCompliance = context.getJpaCompliance();
@ -1132,6 +1138,11 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
return criteriaValueHandlingMode;
}
@Override
public boolean isCriteriaCopyTreeEnabled() {
return criteriaCopyTreeEnabled;
}
@Override
public ImmutableEntityUpdateQueryHandlingMode getImmutableEntityUpdateQueryHandlingMode() {
return immutableEntityUpdateQueryHandlingMode;

View File

@ -378,6 +378,11 @@ public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOp
return delegate.getCriteriaValueHandlingMode();
}
@Override
public boolean isCriteriaCopyTreeEnabled() {
return delegate.isCriteriaCopyTreeEnabled();
}
@Override
public JpaCompliance getJpaCompliance() {
return delegate.getJpaCompliance();

View File

@ -233,10 +233,20 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
TimeZone getJdbcTimeZone();
/**
* @see org.hibernate.cfg.AvailableSettings#CRITERIA_VALUE_HANDLING_MODE
*/
default ValueHandlingMode getCriteriaValueHandlingMode() {
return ValueHandlingMode.BIND;
}
/**
* @see org.hibernate.cfg.AvailableSettings#CRITERIA_COPY_TREE
*/
default boolean isCriteriaCopyTreeEnabled() {
return false;
}
JpaCompliance getJpaCompliance();
boolean isFailOnPaginationOverCollectionFetchEnabled();

View File

@ -2183,6 +2183,26 @@ public interface AvailableSettings {
*/
String CRITERIA_VALUE_HANDLING_MODE = "hibernate.criteria.value_handling_mode";
/**
* When enabled, specifies that {@linkplain org.hibernate.query.Query queries}
* created through {@link jakarta.persistence.EntityManager#createQuery(CriteriaQuery)},
* {@link jakarta.persistence.EntityManager#createQuery(CriteriaUpdate)} or
* {@link jakarta.persistence.EntityManager#createQuery(CriteriaDelete)}
* must create a copy of the passed object such that the resulting {@link jakarta.persistence.Query}
* is not affected by any mutations to the original criteria query.
* <p>
* If disabled, it is assumed that users do not mutate the criteria query afterwards
* and due to that, no copy will be created, which will improve performance.
* <p>
* When bootstrapping Hibernate through the native bootstrap APIs this setting is disabled
* i.e. no copies are created to not hurt performance.
* When bootstrapping Hibernate through the JPA SPI this setting is enabled.
* When enabled, criteria query objects are copied, as required by the Jakarta Persistence specification.
*
* @since 6.0
*/
String CRITERIA_COPY_TREE = "hibernate.criteria.copy_tree";
/**
* Specifies a default value for all {@link org.hibernate.jpa.spi.JpaCompliance}
* flags. Each individual flag may still be overridden by explicitly specifying
@ -2368,24 +2388,6 @@ public interface AvailableSettings {
*/
String JPA_LOAD_BY_ID_COMPLIANCE = "hibernate.jpa.compliance.load_by_id";
/**
* When enabled, specifies that {@linkplain org.hibernate.query.Query queries}
* created through {@link jakarta.persistence.EntityManager#createQuery(CriteriaQuery)},
* {@link jakarta.persistence.EntityManager#createQuery(CriteriaUpdate)} or
* {@link jakarta.persistence.EntityManager#createQuery(CriteriaDelete)}
* must create a copy of the passed object such that the resulting {@link jakarta.persistence.Query}
* is not affected by any mutations to the original criteria query.
* <p>
* If disabled, it is assumed that users do not mutate the criteria query afterwards
* and due to that, no copy will be created, which will improve performance.
* <p>
* By default, no copies are created to not hurt performance. When enabled,
* criteria query objects are copied, as required by the JPA specification.
*
* @since 6.0
*/
String JPA_CRITERIA_COPY_COMPLIANCE = "hibernate.jpa.compliance.criteria_copy";
/**
* Determines if the identifier value stored in the database table backing a
* {@linkplain jakarta.persistence.TableGenerator table generator} is the last

View File

@ -210,13 +210,13 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public void setJpaCriteriaCopyComplianceEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
delegate.setJpaCriteriaCopyComplianceEnabled( jpaCriteriaCopyComplianceEnabled );
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
delegate.setCriteriaCopyTreeEnabled( jpaCriteriaCopyComplianceEnabled );
}
@Override
public boolean isJpaCriteriaCopyComplianceEnabled() {
return delegate.isJpaCriteriaCopyComplianceEnabled();
public boolean isCriteriaCopyTreeEnabled() {
return delegate.isCriteriaCopyTreeEnabled();
}
@Override

View File

@ -332,9 +332,9 @@ public interface SharedSessionContractImplementor
void setCacheMode(CacheMode cm);
void setJpaCriteriaCopyComplianceEnabled(boolean jpaCriteriaCopyComplianceEnabled);
void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled);
boolean isJpaCriteriaCopyComplianceEnabled();
boolean isCriteriaCopyTreeEnabled();
/**
* Set the flush mode for this session.

View File

@ -143,7 +143,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
private final PhysicalConnectionHandlingMode connectionHandlingMode;
private CacheMode cacheMode;
private boolean jpaCriteriaCopyComplianceEnabled;
private boolean criteriaCopyTreeEnabled;
protected boolean closed;
protected boolean waitingForAutoClose;
@ -161,7 +161,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
this.factory = factory;
this.fastSessionServices = factory.getFastSessionServices();
this.cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );
setJpaCriteriaCopyComplianceEnabled( factory.getJpaMetamodel().getJpaCompliance().isJpaCriteriaCopyComplianceEnabled() );
setCriteriaCopyTreeEnabled( factory.getSessionFactoryOptions().isCriteriaCopyTreeEnabled() );
this.flushMode = options.getInitialSessionFlushMode();
@ -647,13 +647,13 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
}
@Override
public void setJpaCriteriaCopyComplianceEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
this.jpaCriteriaCopyComplianceEnabled = jpaCriteriaCopyComplianceEnabled;
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
this.criteriaCopyTreeEnabled = jpaCriteriaCopyComplianceEnabled;
}
@Override
public boolean isJpaCriteriaCopyComplianceEnabled() {
return jpaCriteriaCopyComplianceEnabled;
public boolean isCriteriaCopyTreeEnabled() {
return criteriaCopyTreeEnabled;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -152,7 +152,7 @@ import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_SCOPE;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_TIMEOUT;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_SHARED_CACHE_RETRIEVE_MODE;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_SHARED_CACHE_STORE_MODE;
import static org.hibernate.cfg.AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE;
import static org.hibernate.cfg.AvailableSettings.CRITERIA_COPY_TREE;
import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_SCOPE;
import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT;
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE;
@ -2600,8 +2600,8 @@ public class SessionImpl
)
);
break;
case JPA_CRITERIA_COPY_COMPLIANCE:
setJpaCriteriaCopyComplianceEnabled( Boolean.parseBoolean( value.toString() ) );
case CRITERIA_COPY_TREE:
setCriteriaCopyTreeEnabled( Boolean.parseBoolean( value.toString() ) );
break;
}
}

View File

@ -21,7 +21,6 @@ public class JpaComplianceImpl implements JpaCompliance {
private final boolean closedCompliance;
private final boolean cachingCompliance;
private final boolean loadByIdCompliance;
private final boolean criteriaCopyCompliance;
public JpaComplianceImpl(
boolean listCompliance,
@ -32,8 +31,7 @@ public class JpaComplianceImpl implements JpaCompliance {
boolean transactionCompliance,
boolean closedCompliance,
boolean cachingCompliance,
boolean loadByIdCompliance,
boolean criteriaCopyCompliance) {
boolean loadByIdCompliance) {
this.queryCompliance = queryCompliance;
this.transactionCompliance = transactionCompliance;
this.listCompliance = listCompliance;
@ -43,7 +41,6 @@ public class JpaComplianceImpl implements JpaCompliance {
this.globalGeneratorNameScopeCompliance = globalGeneratorNameScopeCompliance;
this.orderByMappingCompliance = orderByMappingCompliance;
this.loadByIdCompliance = loadByIdCompliance;
this.criteriaCopyCompliance = criteriaCopyCompliance;
}
@Override
@ -91,11 +88,6 @@ public class JpaComplianceImpl implements JpaCompliance {
return loadByIdCompliance;
}
@Override
public boolean isJpaCriteriaCopyComplianceEnabled() {
return criteriaCopyCompliance;
}
public static class JpaComplianceBuilder {
private boolean queryCompliance;
private boolean listCompliance;
@ -106,7 +98,6 @@ public class JpaComplianceImpl implements JpaCompliance {
private boolean transactionCompliance;
private boolean closedCompliance;
private boolean loadByIdCompliance;
private boolean criteriaCopyCompliance;
public JpaComplianceBuilder() {
}
@ -156,11 +147,6 @@ public class JpaComplianceImpl implements JpaCompliance {
return this;
}
public JpaComplianceBuilder setJpaCriteriaCopyComplianceEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
this.criteriaCopyCompliance = jpaCriteriaCopyComplianceEnabled;
return this;
}
JpaCompliance createJpaCompliance() {
return new JpaComplianceImpl(
listCompliance,
@ -171,8 +157,7 @@ public class JpaComplianceImpl implements JpaCompliance {
transactionCompliance,
closedCompliance,
cachingCompliance,
loadByIdCompliance,
criteriaCopyCompliance
loadByIdCompliance
);
}
}

View File

@ -26,7 +26,6 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
private boolean closedCompliance;
private boolean cachingCompliance;
private boolean loadByIdCompliance;
private boolean criteriaCopyCompliance;
public MutableJpaComplianceImpl(Map configurationSettings) {
this(
@ -93,12 +92,6 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
configurationSettings,
jpaByDefault
);
criteriaCopyCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE,
configurationSettings,
jpaByDefault
);
}
@Override
@ -146,11 +139,6 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
return loadByIdCompliance;
}
@Override
public boolean isJpaCriteriaCopyComplianceEnabled() {
return criteriaCopyCompliance;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Mutators
@ -198,11 +186,6 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
this.loadByIdCompliance = enabled;
}
@Override
public void setJpaCriteriaCopyComplianceEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
this.criteriaCopyCompliance = jpaCriteriaCopyComplianceEnabled;
}
@Override
public JpaCompliance immutableCopy() {
JpaComplianceImpl.JpaComplianceBuilder builder = new JpaComplianceImpl.JpaComplianceBuilder();
@ -214,8 +197,7 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
.setTransactionCompliance( transactionCompliance )
.setClosedCompliance( closedCompliance )
.setCachingCompliance( cachingCompliance )
.setLoadByIdCompliance( loadByIdCompliance )
.setJpaCriteriaCopyComplianceEnabled( criteriaCopyCompliance );
.setLoadByIdCompliance( loadByIdCompliance );
return builder.createJpaCompliance();
}
}

View File

@ -155,21 +155,4 @@ public interface JpaCompliance {
*/
boolean isLoadByIdComplianceEnabled();
/**
* JPA says that mutations done to {@link jakarta.persistence.criteria.CriteriaQuery},
* {@link jakarta.persistence.criteria.CriteriaUpdate} and {@link jakarta.persistence.criteria.CriteriaDelete}
* after such objects were used to create a {@link jakarta.persistence.Query} may not affect that query.
* This requirement makes it necessary to copy these objects because the APIs allow mutations.
*
* If disabled, it is assumed that users do not mutate the criteria query afterwards
* and due to that, no copy will be created, which will improve performance.
*
* By default, no copies are created to not hurt performance. When enabled,
* criteria query objects are copied, as required by the JPA specification.
*
* @see org.hibernate.cfg.AvailableSettings#JPA_CRITERIA_COPY_COMPLIANCE
*
* @since 6.0
*/
boolean isJpaCriteriaCopyComplianceEnabled();
}

View File

@ -28,7 +28,5 @@ public interface MutableJpaCompliance extends JpaCompliance {
void setLoadByIdCompliance(boolean enabled);
void setJpaCriteriaCopyComplianceEnabled(boolean jpaCriteriaCopyComplianceEnabled);
JpaCompliance immutableCopy();
}

View File

@ -214,7 +214,7 @@ public class QuerySqmImpl<R>
SharedSessionContractImplementor producer) {
super( producer );
this.hql = CRITERIA_HQL_STRING;
if ( producer.isJpaCriteriaCopyComplianceEnabled() ) {
if ( producer.isCriteriaCopyTreeEnabled() ) {
this.sqm = criteria.copy( SqmCopyContext.simpleContext() );
}
else {
@ -1010,7 +1010,7 @@ public class QuerySqmImpl<R>
public NamedQueryMemento toMemento(String name) {
if ( CRITERIA_HQL_STRING.equals( getQueryString() ) ) {
final SqmStatement sqmStatement ;
if ( !getSession().isJpaCriteriaCopyComplianceEnabled() ) {
if ( !getSession().isCriteriaCopyTreeEnabled() ) {
sqmStatement = getSqmStatement().copy( SqmCopyContext.simpleContext() );
}
else {

View File

@ -54,7 +54,6 @@ import org.hibernate.query.spi.ScrollableResultsImplementor;
import org.hibernate.query.spi.SelectQueryPlan;
import org.hibernate.query.sqm.SqmSelectionQuery;
import org.hibernate.query.sqm.internal.SqmInterpretationsKey.InterpretationsKeySource;
import org.hibernate.query.sqm.spi.NamedSqmQueryMemento;
import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.expression.JpaCriteriaParameter;
import org.hibernate.query.sqm.tree.expression.SqmJpaCriteriaParameterWrapper;
@ -157,7 +156,7 @@ public class SqmSelectionQueryImpl<R> extends AbstractSelectionQuery<R> implemen
SharedSessionContractImplementor session) {
super( session );
this.hql = CRITERIA_HQL_STRING;
if ( session.isJpaCriteriaCopyComplianceEnabled() ) {
if ( session.isCriteriaCopyTreeEnabled() ) {
this.sqm = criteria.copy( SqmCopyContext.simpleContext() );
}
else {

View File

@ -58,9 +58,4 @@ public class JpaComplianceStub implements JpaCompliance {
public boolean isLoadByIdComplianceEnabled() {
return false;
}
@Override
public boolean isJpaCriteriaCopyComplianceEnabled() {
return false;
}
}

View File

@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@Jpa(
annotatedClasses = CriteriaDeleteTest.Person.class,
criteriaCopyComplianceEnabled = true
jpaComplianceEnabled = true
)
public class CriteriaDeleteTest {

View File

@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
}
,
properties = {
@Setting(name = AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE, value = "true"),
@Setting(name = AvailableSettings.CRITERIA_COPY_TREE, value = "true"),
}
)
public class CriteriaMutationQueryTableTest {

View File

@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
}
,
properties = {
@Setting(name = AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE, value = "true"),
@Setting(name = AvailableSettings.CRITERIA_COPY_TREE, value = "true"),
}
)
public class CriteriaMutationQueryWithSecondaryTableTest {

View File

@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
CriteriaPredicateTest.Deposit.class
},
properties = {
@Setting(name = AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE, value = "true"),
@Setting(name = AvailableSettings.CRITERIA_COPY_TREE, value = "true"),
}
)
public class CriteriaPredicateTest {

View File

@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
}
,
properties = {
@Setting(name = AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE, value = "true"),
@Setting(name = AvailableSettings.CRITERIA_COPY_TREE, value = "true"),
}
)
public class JoinTest {

View File

@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@Jpa(
annotatedClasses = NamedQueryTest.Person.class,
properties = @Setting(name = AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE, value = "true")
properties = @Setting(name = AvailableSettings.CRITERIA_COPY_TREE, value = "true")
)
public class NamedQueryTest {

View File

@ -26,7 +26,6 @@ import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableMutationStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.tool.schema.Action;
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.ActionGrouping;
@ -89,6 +88,7 @@ public class EntityManagerFactoryExtension
pui.setExcludeUnlistedClasses( emfAnn.excludeUnlistedClasses() );
// JpaCompliance
pui.getProperties().put( AvailableSettings.JPA_COMPLIANCE, emfAnn.jpaComplianceEnabled() );
pui.getProperties().put( AvailableSettings.JPA_QUERY_COMPLIANCE, emfAnn.queryComplianceEnabled() );
pui.getProperties().put( AvailableSettings.JPA_TRANSACTION_COMPLIANCE, emfAnn.transactionComplianceEnabled() );
pui.getProperties().put( AvailableSettings.JPA_LIST_COMPLIANCE, emfAnn.listMappingComplianceEnabled() );
@ -98,7 +98,6 @@ public class EntityManagerFactoryExtension
pui.getProperties().put( AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE, emfAnn.generatorScopeComplianceEnabled() );
pui.getProperties().put( AvailableSettings.JPA_ORDER_BY_MAPPING_COMPLIANCE, emfAnn.orderByMappingComplianceEnabled() );
pui.getProperties().put( AvailableSettings.JPA_LOAD_BY_ID_COMPLIANCE, emfAnn.loadByIdComplianceEnabled() );
pui.getProperties().put( AvailableSettings.JPA_CRITERIA_COPY_COMPLIANCE, emfAnn.criteriaCopyComplianceEnabled() );
final Setting[] properties = emfAnn.properties();
for ( int i = 0; i < properties.length; i++ ) {

View File

@ -63,6 +63,11 @@ public @interface Jpa {
SharedCacheMode sharedCacheMode() default SharedCacheMode.UNSPECIFIED;
ValidationMode validationMode() default ValidationMode.NONE;
/**
* @see org.hibernate.cfg.AvailableSettings#JPA_COMPLIANCE
*/
boolean jpaComplianceEnabled() default false;
/**
* @see JpaCompliance#isJpaQueryComplianceEnabled()
*/
@ -109,11 +114,6 @@ public @interface Jpa {
*/
boolean loadByIdComplianceEnabled() default false;
/**
* @see JpaCompliance#isLoadByIdComplianceEnabled()
*/
boolean criteriaCopyComplianceEnabled() default false;
boolean excludeUnlistedClasses() default false;
StandardDomainModel[] standardModels() default {};

View File

@ -318,15 +318,15 @@ todo (6.0) - cover bulk manipulation query handling
[[query-criteria-copy]]
== JPA Criteria behavior change
== Hibernate Criteria behavior change
Without JPA compliance (`hibernate.jpa.compliance`) or when the newly introduced `hibernate.jpa.compliance.criteria_copy` configuration property
is disabled, it is expected that criteria queries passed to `jakarta.persistence.EntityManager#createQuery(CriteriaQuery)`,
`jakarta.persistence.EntityManager#createQuery(CriteriaUpdate)` or `jakarta.persistence.EntityManager#createQuery(CriteriaDelete)`
are not mutated afterwards to avoid the need for copying the criteria query.
By default, when bootstrapping Hibernate through the native bootstrap APIs or when explicitly disabling the newly introduced
`hibernate.criteria.copy_tree` configuration property, it is expected that criteria queries passed to
`jakarta.persistence.EntityManager#createQuery(CriteriaQuery)`, `jakarta.persistence.EntityManager#createQuery(CriteriaUpdate)`
or `jakarta.persistence.EntityManager#createQuery(CriteriaDelete)` are not mutated afterwards to avoid the need for copying the criteria query.
Prior to 6.0, mutations to criteria queries didn't affect `Query` instances created from that.
To retain backwards compatibility, enable the `hibernate.jpa.compliance.criteria_copy` configuration property.
To retain backwards compatibility, enable the `hibernate.criteria.copy_tree` configuration property.
[[query-sqm-rows]]
==== Result "rows"