api, spi, internal, deprecation

org.hibernate.jpa
This commit is contained in:
Steve Ebersole 2022-01-20 22:19:02 -06:00
parent e1e16a5041
commit 5761e7801b
38 changed files with 905 additions and 555 deletions

View File

@ -40,33 +40,33 @@ public class AcmeCorpPhysicalNamingStrategy extends PhysicalNamingStrategyStanda
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
final List<String> parts = splitAndReplace(name.getText());
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
final List<String> parts = splitAndReplace( logicalName.getText());
return jdbcEnvironment.getIdentifierHelper().toIdentifier(
StringUtils.join(parts, '_'),
name.isQuoted()
logicalName.isQuoted()
);
}
@Override
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) {
final List<String> parts = splitAndReplace(name.getText());
public Identifier toPhysicalSequenceName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
final List<String> parts = splitAndReplace( logicalName.getText());
// Acme Corp says all sequences should end with _seq
if (!"seq".equals(parts.get(parts.size() - 1))) {
parts.add("seq");
}
return jdbcEnvironment.getIdentifierHelper().toIdentifier(
StringUtils.join(parts, '_'),
name.isQuoted()
logicalName.isQuoted()
);
}
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
final List<String> parts = splitAndReplace(name.getText());
public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
final List<String> parts = splitAndReplace( logicalName.getText());
return jdbcEnvironment.getIdentifierHelper().toIdentifier(
StringUtils.join(parts, '_'),
name.isQuoted()
logicalName.isQuoted()
);
}

View File

@ -6,7 +6,9 @@
*/
package org.hibernate.annotations;
import org.hibernate.FlushMode;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.jpa.LegacySpecHints;
import org.hibernate.jpa.SpecHints;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
@ -16,9 +18,10 @@ import org.hibernate.query.Query;
* the {@link Query} interface, and so hints are only necessary for programs
* working with the JPA APIs.
*
* @see org.hibernate.jpa.QueryHints
* @see SpecHints
* @see HibernateHints
*/
public class QueryHints {
public class QueryHints implements HibernateHints, SpecHints {
/**
* Disallow instantiation.
*/
@ -26,124 +29,76 @@ public class QueryHints {
}
/**
* The cache mode to use.
*
* @see Query#setCacheMode
* @see NativeQuery#setCacheMode
* @see HibernateHints#HINT_READ_ONLY
*/
public static final String CACHE_MODE = "org.hibernate.cacheMode";
public static final String READ_ONLY = HibernateHints.HINT_READ_ONLY;
/**
* The cache region to use.
*
* @see Query#setCacheRegion
* @see NativeQuery#setCacheRegion
* @see HibernateHints#HINT_CACHEABLE
*/
public static final String CACHE_REGION = "org.hibernate.cacheRegion";
public static final String CACHEABLE = HibernateHints.HINT_CACHEABLE;
/**
* Are the query results cacheable?
*
* @see Query#setCacheable
* @see NativeQuery#setCacheable
* @see HibernateHints#HINT_CACHE_MODE
*/
public static final String CACHEABLE = "org.hibernate.cacheable";
public static final String CACHE_MODE = HibernateHints.HINT_CACHE_MODE;
/**
* Is the named stored procedure a function?
* @see HibernateHints#HINT_CACHE_REGION
*/
public static final String CACHE_REGION = HibernateHints.HINT_CACHE_REGION;
/**
* @see HibernateHints#HINT_COMMENT
*/
public static final String COMMENT = HibernateHints.HINT_COMMENT;
/**
* @see HibernateHints#HINT_FETCH_SIZE
*/
public static final String FETCH_SIZE = HibernateHints.HINT_FETCH_SIZE;
/**
* @see HibernateHints#HINT_FLUSH_MODE
*/
public static final String FLUSH_MODE = HibernateHints.HINT_FLUSH_MODE;
/**
* @see HibernateHints#HINT_TIMEOUT
*/
public static final String TIMEOUT_HIBERNATE = HibernateHints.HINT_TIMEOUT;
/**
* @see org.hibernate.jpa.SpecHints#HINT_QUERY_TIMEOUT
*/
public static final String TIMEOUT_JAKARTA_JPA = SpecHints.HINT_QUERY_TIMEOUT;
/**
* @see HibernateHints#HINT_NATIVE_LOCK_MODE
*/
public static final String NATIVE_LOCKMODE = HibernateHints.HINT_NATIVE_LOCK_MODE;
/**
* @see HibernateHints#HINT_FOLLOW_ON_LOCKING
*/
public static final String FOLLOW_ON_LOCKING = HibernateHints.HINT_FOLLOW_ON_LOCKING;
/**
* @see QueryHints#NATIVE_SPACES
*/
public static final String NATIVE_SPACES = HibernateHints.HINT_NATIVE_SPACES;
/**
* @deprecated Calling stored-procedures and functions via
* {@link NativeQuery} is no longer supported. Use
* {@link org.hibernate.procedure.ProcedureCall} or
* {@link jakarta.persistence.StoredProcedureQuery} instead
*/
@Deprecated
public static final String CALLABLE_FUNCTION = "org.hibernate.callableFunction";
/**
* Defines a comment to be applied to the SQL sent to the database.
*
* @see Query#setComment
* @see NativeQuery#setComment
* @see org.hibernate.jpa.SpecHints#HINT_QUERY_TIMEOUT
*/
public static final String COMMENT = "org.hibernate.comment";
/**
* Defines the JDBC fetch size to use.
*
* @see Query#setFetchSize
* @see NativeQuery#setFetchSize
*/
public static final String FETCH_SIZE = "org.hibernate.fetchSize";
/**
* The flush mode to associate with the execution of the query.
*
* @see Query#setHibernateFlushMode
* @see NativeQuery#setHibernateFlushMode
* @see org.hibernate.Session#setHibernateFlushMode
*/
public static final String FLUSH_MODE = "org.hibernate.flushMode";
/**
* Should entities returned from the query be set in read only mode?
*
* @see Query#setReadOnly
* @see NativeQuery#setReadOnly
* @see org.hibernate.Session#setReadOnly
*/
public static final String READ_ONLY = "org.hibernate.readOnly";
/**
* Apply a Hibernate query timeout, which is defined in <b>seconds</b>.
*
* @see Query#setTimeout
* @see NativeQuery#setTimeout
*/
public static final String TIMEOUT_HIBERNATE = "org.hibernate.timeout";
/**
* Apply a JPA query timeout, which is defined in <b>milliseconds</b>.
*/
public static final String TIMEOUT_JPA = "javax.persistence.query.timeout";
/**
* Apply a JPA query timeout, which is defined in <b>milliseconds</b>.
*/
public static final String TIMEOUT_JAKARTA_JPA = "jakarta.persistence.query.timeout";
/**
* Apply lock mode to a native SQL query since JPA requires that
* {@link jakarta.persistence.Query#setLockMode} throw an {@code IllegalStateException}
* if called for a native query.
* <p/>
* Accepts a {@link jakarta.persistence.LockModeType} or a {@link org.hibernate.LockMode}
*/
public static final String NATIVE_LOCKMODE = "org.hibernate.lockMode";
/**
* Hint to enable/disable the follow-on-locking mechanism provided by
* {@link org.hibernate.dialect.Dialect#useFollowOnLocking(String, org.hibernate.query.spi.QueryOptions)}.
* A value of {@code true} enables follow-on-locking, whereas a value of
* {@code false} disables it. If the value is {@code null}, the
* {@code Dialect}'s default strategy is used.
*
* @since 5.2
*/
public static final String FOLLOW_ON_LOCKING = "hibernate.query.followOnLocking";
/**
* Hint for specifying query spaces to be applied to a native (SQL) query.
*
* Passed value can be any of:<ul>
* <li>List of the spaces</li>
* <li>array of the spaces</li>
* <li>String as "whitespace"-separated list of the spaces</li>
* </ul>
*
* Note that the passed space need not match any real spaces/tables in
* the underlying query. This can be used to completely circumvent
* the auto-flush checks as well as any cache invalidation that might
* occur as part of a flush. See {@link org.hibernate.query.SynchronizeableQuery}
* and {@link FlushMode#MANUAL} for more information.
*
* @see org.hibernate.SynchronizeableQuery
* @see #FLUSH_MODE
*/
public static final String NATIVE_SPACES = "org.hibernate.query.native.spaces";
public static final String TIMEOUT_JPA = LegacySpecHints.HINT_JAVAEE_QUERY_TIMEOUT;
}

View File

@ -78,12 +78,12 @@ public class AttributeConverterManager implements ConverterAutoApplyHandler {
}
@Override
public ConverterDescriptor findAutoApplyConverterForAttribute(
XProperty xProperty,
XProperty property,
MetadataBuildingContext context) {
return locateMatchingConverter(
xProperty,
property,
ConversionSite.ATTRIBUTE,
(autoApplyDescriptor) -> autoApplyDescriptor.getAutoAppliedConverterDescriptorForAttribute( xProperty, context )
(autoApplyDescriptor) -> autoApplyDescriptor.getAutoAppliedConverterDescriptorForAttribute( property, context )
);
}
@ -138,23 +138,23 @@ public class AttributeConverterManager implements ConverterAutoApplyHandler {
@Override
public ConverterDescriptor findAutoApplyConverterForCollectionElement(
XProperty xProperty,
XProperty property,
MetadataBuildingContext context) {
return locateMatchingConverter(
xProperty,
property,
ConversionSite.COLLECTION_ELEMENT,
(autoApplyDescriptor) -> autoApplyDescriptor.getAutoAppliedConverterDescriptorForCollectionElement( xProperty, context )
(autoApplyDescriptor) -> autoApplyDescriptor.getAutoAppliedConverterDescriptorForCollectionElement( property, context )
);
}
@Override
public ConverterDescriptor findAutoApplyConverterForMapKey(
XProperty xProperty,
XProperty property,
MetadataBuildingContext context) {
return locateMatchingConverter(
xProperty,
property,
ConversionSite.MAP_KEY,
(autoApplyDescriptor) -> autoApplyDescriptor.getAutoAppliedConverterDescriptorForMapKey( xProperty, context )
(autoApplyDescriptor) -> autoApplyDescriptor.getAutoAppliedConverterDescriptorForMapKey( property, context )
);
}

View File

@ -9,11 +9,41 @@ package org.hibernate.boot.model.convert.spi;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.MetadataBuildingContext;
import jakarta.persistence.Converter;
/**
* Manages resolution of auto-applied {@link jakarta.persistence.AttributeConverter}
* references for specific mappings
*
* @see Converter#autoApply()
*
* @author Steve Ebersole
*/
public interface ConverterAutoApplyHandler {
ConverterDescriptor findAutoApplyConverterForAttribute(XProperty xProperty, MetadataBuildingContext context);
ConverterDescriptor findAutoApplyConverterForCollectionElement(XProperty xProperty, MetadataBuildingContext context);
ConverterDescriptor findAutoApplyConverterForMapKey(XProperty xProperty, MetadataBuildingContext context);
/**
* Resolve the auto-applied converter to be applied to a basic attribute described
* by the passed property descriptor. {@code null} indicates that no auto-applied
* converter matched
*
* @param property The HCANN descriptor for the basic attribute
*/
ConverterDescriptor findAutoApplyConverterForAttribute(XProperty property, MetadataBuildingContext context);
/**
* Resolve the auto-applied converter to be applied to the elements of a plural attribute
* described by the passed property descriptor. {@code null} indicates that no auto-applied
* converter matched
*
* @param property The HCANN descriptor for the plural attribute
*/
ConverterDescriptor findAutoApplyConverterForCollectionElement(XProperty property, MetadataBuildingContext context);
/**
* Resolve the auto-applied converter to be applied to the keys of a plural Map attribute
* described by the passed property descriptor. {@code null} indicates that no auto-applied
* converter matched
*
* @param property The HCANN descriptor for the plural Map attribute
*/
ConverterDescriptor findAutoApplyConverterForMapKey(XProperty property, MetadataBuildingContext context);
}

View File

@ -20,28 +20,28 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
public class CamelCaseToUnderscoresNamingStrategy implements PhysicalNamingStrategy {
@Override
public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return apply( name, jdbcEnvironment );
public Identifier toPhysicalCatalogName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return apply( logicalName, jdbcEnvironment );
}
@Override
public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return apply( name, jdbcEnvironment );
public Identifier toPhysicalSchemaName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return apply( logicalName, jdbcEnvironment );
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return apply( name, jdbcEnvironment );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return apply( logicalName, jdbcEnvironment );
}
@Override
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return apply( name, jdbcEnvironment );
public Identifier toPhysicalSequenceName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return apply( logicalName, jdbcEnvironment );
}
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return apply( name, jdbcEnvironment );
public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return apply( logicalName, jdbcEnvironment );
}
private Identifier apply(final Identifier name, final JdbcEnvironment jdbcEnvironment) {

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.boot.model.naming;
import org.hibernate.Incubating;
/**
* Pluggable strategy for applying implicit naming rules when an
* explicit name is not given.
@ -45,6 +47,7 @@ package org.hibernate.boot.model.naming;
*
* @author Steve Ebersole
*/
@Incubating
public interface ImplicitNamingStrategy {
/**
* Determine the implicit name of an entity's primary table.
@ -53,7 +56,7 @@ public interface ImplicitNamingStrategy {
*
* @return The implicit table name.
*/
public Identifier determinePrimaryTableName(ImplicitEntityNameSource source);
Identifier determinePrimaryTableName(ImplicitEntityNameSource source);
/**
* Determine the name of an association join table given the source naming
@ -63,7 +66,7 @@ public interface ImplicitNamingStrategy {
*
* @return The implicit table name.
*/
public Identifier determineJoinTableName(ImplicitJoinTableNameSource source);
Identifier determineJoinTableName(ImplicitJoinTableNameSource source);
/**
* Determine the name of a collection join table given the source naming
@ -73,7 +76,7 @@ public interface ImplicitNamingStrategy {
*
* @return The implicit table name.
*/
public Identifier determineCollectionTableName(ImplicitCollectionTableNameSource source);
Identifier determineCollectionTableName(ImplicitCollectionTableNameSource source);
/**
@ -83,7 +86,7 @@ public interface ImplicitNamingStrategy {
*
* @return The implicit discriminator column name
*/
public Identifier determineDiscriminatorColumnName(ImplicitDiscriminatorColumnNameSource source);
Identifier determineDiscriminatorColumnName(ImplicitDiscriminatorColumnNameSource source);
/**
* Determine the implicit name for the tenant (multi-tenancy) identifier column for the given entity
@ -92,7 +95,7 @@ public interface ImplicitNamingStrategy {
*
* @return The determined tenant identifier column name
*/
public Identifier determineTenantIdColumnName(ImplicitTenantIdColumnNameSource source);
Identifier determineTenantIdColumnName(ImplicitTenantIdColumnNameSource source);
/**
* Determine the implicit name for the identifier column for the given entity
@ -101,7 +104,7 @@ public interface ImplicitNamingStrategy {
*
* @return The determined identifier column name
*/
public Identifier determineIdentifierColumnName(ImplicitIdentifierColumnNameSource source);
Identifier determineIdentifierColumnName(ImplicitIdentifierColumnNameSource source);
/**
* Determine the name of an attribute's column given the source naming
@ -111,7 +114,7 @@ public interface ImplicitNamingStrategy {
*
* @return The implicit column name.
*/
public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source);
Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source);
/**
* Determine the column name related to {@link jakarta.persistence.JoinColumn}. In
@ -122,7 +125,7 @@ public interface ImplicitNamingStrategy {
*
* @return The determined join column name
*/
public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source);
Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source);
/**
* Determine the column name related to {@link jakarta.persistence.PrimaryKeyJoinColumn}. In
@ -133,7 +136,7 @@ public interface ImplicitNamingStrategy {
*
* @return The determined column name
*/
public Identifier determinePrimaryKeyJoinColumnName(ImplicitPrimaryKeyJoinColumnNameSource source);
Identifier determinePrimaryKeyJoinColumnName(ImplicitPrimaryKeyJoinColumnNameSource source);
/**
* Determine the column name related to the discriminator portion of an ANY mapping when

View File

@ -6,25 +6,38 @@
*/
package org.hibernate.boot.model.naming;
import org.hibernate.Incubating;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
/**
* Pluggable strategy contract for applying physical naming rules for database object names.
*
* NOTE: Ideally we'd pass "extra" things in here like Dialect, etc to better handle identifier
* length constraints or auto quoting of identifiers. However, the pre-metamodel model does not
* necessarily know this information at the time the strategy is called.
*
* @author Steve Ebersole
*/
@Incubating
public interface PhysicalNamingStrategy {
public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment jdbcEnvironment);
/**
* Determine the appropriate physical catalog name to use for the given logical name
*/
Identifier toPhysicalCatalogName(Identifier logicalName, JdbcEnvironment jdbcEnvironment);
public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment jdbcEnvironment);
/**
* Determine the appropriate physical schema name to use for the given logical name
*/
Identifier toPhysicalSchemaName(Identifier logicalName, JdbcEnvironment jdbcEnvironment);
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment);
/**
* Determine the appropriate physical table name to use for the given logical name
*/
Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment);
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment);
/**
* Determine the appropriate physical sequence name to use for the given logical name
*/
Identifier toPhysicalSequenceName(Identifier logicalName, JdbcEnvironment jdbcEnvironment);
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment);
/**
* Determine the appropriate physical column name to use for the given logical name
*/
Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment);
}

View File

@ -22,27 +22,27 @@ public class PhysicalNamingStrategyStandardImpl implements PhysicalNamingStrateg
public static final PhysicalNamingStrategyStandardImpl INSTANCE = new PhysicalNamingStrategyStandardImpl();
@Override
public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment context) {
return name;
public Identifier toPhysicalCatalogName(Identifier logicalName, JdbcEnvironment context) {
return logicalName;
}
@Override
public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment context) {
return name;
public Identifier toPhysicalSchemaName(Identifier logicalName, JdbcEnvironment context) {
return logicalName;
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
return name;
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment context) {
return logicalName;
}
@Override
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment context) {
return name;
public Identifier toPhysicalSequenceName(Identifier logicalName, JdbcEnvironment context) {
return logicalName;
}
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) {
return name;
public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment context) {
return logicalName;
}
}

View File

@ -224,30 +224,17 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
void addIdentifierGenerator(IdentifierGeneratorDefinition generatorDefinition);
/**
* @deprecated AttributeConverterDefinition forces early resolution of the
* AttributeConverter instance, which precludes resolution of the converter
* from {@link org.hibernate.resource.beans.spi.ManagedBeanRegistry} (CDI, etc).
* Instead one of:
* * {@link #addAttributeConverter(ConverterDescriptor)}
* * {@link #addAttributeConverter(Class)}
* * {@link #addAttributeConverter(Class)}
* Apply the descriptor for an {@link AttributeConverter}
*/
@Deprecated
default void addAttributeConverter(AttributeConverterDefinition converter) {
addAttributeConverter(
new InstanceBasedConverterDescriptor(
converter.getAttributeConverter(),
getBootstrapContext().getClassmateContext()
)
);
}
void addAttributeConverter(ConverterDescriptor descriptor);
/**
* Apply an {@link AttributeConverter}
*/
void addAttributeConverter(Class<? extends AttributeConverter> converterClass);
ConverterAutoApplyHandler getAttributeConverterAutoApplyHandler();

View File

@ -9,6 +9,7 @@ package org.hibernate.cfg;
import java.util.function.Supplier;
import org.hibernate.HibernateException;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
import org.hibernate.Transaction;
@ -32,6 +33,7 @@ import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
import org.hibernate.tool.schema.JdbcMetadaAccessStrategy;
import org.hibernate.tool.schema.SourceType;
import org.hibernate.tool.schema.UniqueConstraintSchemaUpdateStrategy;
import org.hibernate.tool.schema.internal.script.SingleLineSqlScriptExtractor;
/**
* @author Steve Ebersole
@ -125,24 +127,14 @@ public interface AvailableSettings {
String JAKARTA_SHARED_CACHE_MODE = "jakarta.persistence.sharedCache.mode";
/**
* NOTE : Not a valid EMF property...
* <p/>
* Used to indicate if the provider should attempt to retrieve requested data
* in the shared cache.
*
* @see jakarta.persistence.CacheRetrieveMode
* @see org.hibernate.jpa.SpecHints#HINT_CACHE_RETRIEVE_MODE
*/
String JAKARTA_SHARED_CACHE_RETRIEVE_MODE ="jakarta.persistence.cache.retrieveMode";
String JAKARTA_SHARED_CACHE_RETRIEVE_MODE = org.hibernate.jpa.SpecHints.HINT_CACHE_RETRIEVE_MODE;
/**
* NOTE : Not a valid EMF property...
* <p/>
* Used to indicate if the provider should attempt to store data loaded from the database
* in the shared cache.
*
* @see jakarta.persistence.CacheStoreMode
* @see org.hibernate.jpa.SpecHints#HINT_CACHE_STORE_MODE
*/
String JAKARTA_SHARED_CACHE_STORE_MODE ="jakarta.persistence.cache.storeMode";
String JAKARTA_SHARED_CACHE_STORE_MODE = org.hibernate.jpa.SpecHints.HINT_CACHE_STORE_MODE;
/**
* Used to indicate what form of automatic validation is in effect as per rules defined
@ -1415,7 +1407,7 @@ public interface AvailableSettings {
String HBM2DDL_LOAD_SCRIPT_SOURCE = "javax.persistence.sql-load-script-source";
/**
* Reference to the {@link org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor} implementation class
* Reference to the {@link org.hibernate.tool.schema.spi.SqlScriptCommandExtractor} implementation class
* to use for parsing source/import files as defined by {@link #HBM2DDL_CREATE_SCRIPT_SOURCE},
* {@link #HBM2DDL_DROP_SCRIPT_SOURCE} or {@link #HBM2DDL_IMPORT_FILES}.
* <p/>
@ -1423,7 +1415,7 @@ public interface AvailableSettings {
* of the ImportSqlCommandExtractor implementation. If the FQN is given, the implementation
* must provide a no-arg constructor.
* <p/>
* The default value is {@link org.hibernate.tool.hbm2ddl.SingleLineSqlCommandExtractor}.
* The default value is {@link SingleLineSqlScriptExtractor}.
*/
String HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR = "hibernate.hbm2ddl.import_files_sql_extractor";
@ -2485,6 +2477,8 @@ public interface AvailableSettings {
/**
* Used to determine flush mode.
*
* @see HibernateHints#HINT_FLUSH_MODE
*/
String FLUSH_MODE = "org.hibernate.flushMode";

View File

@ -6,6 +6,24 @@
*/
package org.hibernate.cfg.annotations;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.annotations.CacheModeType;
import org.hibernate.annotations.FlushModeType;
import org.hibernate.boot.internal.NamedHqlQueryDefinitionImpl;
import org.hibernate.boot.internal.NamedProcedureCallDefinitionImpl;
import org.hibernate.boot.query.NamedHqlQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinitionBuilder;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jpa.HibernateHints;
import org.jboss.logging.Logger;
import jakarta.persistence.NamedNativeQueries;
import jakarta.persistence.NamedNativeQuery;
import jakarta.persistence.NamedQueries;
@ -14,24 +32,6 @@ import jakarta.persistence.NamedStoredProcedureQuery;
import jakarta.persistence.SqlResultSetMapping;
import jakarta.persistence.SqlResultSetMappings;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.annotations.CacheModeType;
import org.hibernate.annotations.FlushModeType;
import org.hibernate.annotations.QueryHints;
import org.hibernate.boot.internal.NamedHqlQueryDefinitionImpl;
import org.hibernate.boot.internal.NamedProcedureCallDefinitionImpl;
import org.hibernate.boot.query.NamedNativeQueryDefinitionBuilder;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.query.NamedHqlQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinition;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
/**
* Query binder
*
@ -65,13 +65,13 @@ public abstract class QueryBinder {
.setHqlString( queryString )
.setCacheable( hints.getCacheability() )
.setCacheMode( hints.getCacheMode() )
.setCacheRegion( hints.getString( QueryHints.CACHE_REGION ) )
.setCacheRegion( hints.getString( HibernateHints.HINT_CACHE_REGION ) )
.setTimeout( hints.getTimeout() )
.setFetchSize( hints.getInteger( QueryHints.FETCH_SIZE ) )
.setFetchSize( hints.getInteger( HibernateHints.HINT_FETCH_SIZE ) )
.setFlushMode( hints.getFlushMode() )
.setReadOnly( hints.getBoolean( QueryHints.READ_ONLY ) )
.setReadOnly( hints.getBoolean( HibernateHints.HINT_READ_ONLY ) )
.setLockOptions( hints.determineLockOptions( queryAnn ) )
.setComment( hints.getString( QueryHints.COMMENT ) )
.setComment( hints.getString( HibernateHints.HINT_COMMENT ) )
.build();
if ( isDefault ) {
@ -112,12 +112,12 @@ public abstract class QueryBinder {
.setQuerySpaces( null )
.setCacheable( hints.getCacheability() )
.setCacheMode( hints.getCacheMode() )
.setCacheRegion( hints.getString( QueryHints.CACHE_REGION ) )
.setCacheRegion( hints.getString( HibernateHints.HINT_CACHE_REGION ) )
.setTimeout( hints.getTimeout() )
.setFetchSize( hints.getInteger( QueryHints.FETCH_SIZE ) )
.setFetchSize( hints.getInteger( HibernateHints.HINT_FETCH_SIZE ) )
.setFlushMode( hints.getFlushMode() )
.setReadOnly( hints.getBoolean( QueryHints.READ_ONLY ) )
.setComment( hints.getString( QueryHints.COMMENT ) )
.setReadOnly( hints.getBoolean( HibernateHints.HINT_READ_ONLY ) )
.setComment( hints.getString( HibernateHints.HINT_COMMENT ) )
.addHints( hints.getHintsMap() );

View File

@ -9,9 +9,6 @@ package org.hibernate.cfg.annotations;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import jakarta.persistence.LockModeType;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.QueryHint;
import org.hibernate.AnnotationException;
import org.hibernate.CacheMode;
@ -19,10 +16,16 @@ import org.hibernate.FlushMode;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.MappingException;
import org.hibernate.annotations.QueryHints;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.util.LockModeConverter;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.jpa.LegacySpecHints;
import org.hibernate.jpa.SpecHints;
import jakarta.persistence.LockModeType;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.QueryHint;
/**
* @author <a href="mailto:stliu@hibernate.org">Strong Liu</a>
@ -80,21 +83,27 @@ public class QueryHintDefinition {
// Specialized access
public Integer getTimeout() {
final Integer jpaTimeout = getInteger( QueryHints.TIMEOUT_JPA );
if ( jpaTimeout != null ) {
final Integer jakartaTimeout = getInteger( SpecHints.HINT_QUERY_TIMEOUT );
if ( jakartaTimeout != null ) {
// convert milliseconds to seconds
return (int) Math.round( jpaTimeout.doubleValue() / 1000.0 );
return (int) Math.round( jakartaTimeout.doubleValue() / 1000.0 );
}
return getInteger( QueryHints.TIMEOUT_HIBERNATE );
final Integer javaeeTimeout = getInteger( LegacySpecHints.HINT_JAVAEE_QUERY_TIMEOUT );
if ( javaeeTimeout != null ) {
// convert milliseconds to seconds
return (int) Math.round( javaeeTimeout.doubleValue() / 1000.0 );
}
return getInteger( HibernateHints.HINT_TIMEOUT );
}
public boolean getCacheability() {
return getBoolean( QueryHints.CACHEABLE );
return getBoolean( HibernateHints.HINT_CACHEABLE );
}
public CacheMode getCacheMode() {
final String value = getString( QueryHints.CACHE_MODE );
final String value = getString( HibernateHints.HINT_CACHE_MODE );
try {
return value == null
? null
@ -106,7 +115,7 @@ public class QueryHintDefinition {
}
public FlushMode getFlushMode() {
final String value = getString( QueryHints.FLUSH_MODE );
final String value = getString( HibernateHints.HINT_FLUSH_MODE );
try {
return value == null
? null
@ -118,7 +127,7 @@ public class QueryHintDefinition {
}
public LockMode getLockMode(String query) {
String hitName = QueryHints.NATIVE_LOCKMODE;
String hitName = HibernateHints.HINT_NATIVE_LOCK_MODE;
String value =(String) hintsMap.get( hitName );
if ( value == null ) {
return null;
@ -132,16 +141,22 @@ public class QueryHintDefinition {
}
public LockOptions determineLockOptions(NamedQuery namedQueryAnnotation) {
LockModeType lockModeType = namedQueryAnnotation.lockMode();
Integer lockTimeoutHint = getInteger( AvailableSettings.JPA_LOCK_TIMEOUT );
if ( lockTimeoutHint == null ) {
lockTimeoutHint = getInteger( AvailableSettings.JAKARTA_LOCK_TIMEOUT );
}
Boolean followOnLocking = getBoolean( QueryHints.FOLLOW_ON_LOCKING );
final LockModeType lockModeType = namedQueryAnnotation.lockMode();
final Integer lockTimeoutHint = specLockTimeout();
final Boolean followOnLocking = getBoolean( HibernateHints.HINT_FOLLOW_ON_LOCKING );
return determineLockOptions(lockModeType, lockTimeoutHint, followOnLocking);
}
private Integer specLockTimeout() {
final Integer jakartaLockTimeout = getInteger( AvailableSettings.JAKARTA_LOCK_TIMEOUT );
if ( jakartaLockTimeout != null ) {
return jakartaLockTimeout;
}
return getInteger( AvailableSettings.JPA_LOCK_TIMEOUT );
}
private LockOptions determineLockOptions(LockModeType lockModeType, Integer lockTimeoutHint, Boolean followOnLocking) {
LockOptions lockOptions = new LockOptions( LockModeConverter.convertToLockMode( lockModeType ) )

View File

@ -116,10 +116,10 @@ public class EffectiveEntityGraph implements AppliedGraph, Serializable {
RootGraphImplementor fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJpaHintName() );
RootGraphImplementor loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJpaHintName() );
if (fetchHint == null) {
fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJakartaJpaHintName() );
fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJakartaHintName() );
}
if (loadHint == null) {
loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJakartaJpaHintName() );
loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJakartaHintName() );
}
if ( fetchHint == null && loadHint == null ) {

View File

@ -6,9 +6,14 @@
*/
package org.hibernate.graph;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_FETCH_GRAPH;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_LOAD_GRAPH;
import static org.hibernate.jpa.SpecHints.HINT_FETCH_GRAPH;
import static org.hibernate.jpa.SpecHints.HINT_LOAD_GRAPH;
/**
* JPA specifies two distinct ways to apply an {@link jakarta.persistence.EntityGraph},
* as a {@link #FETCH "fetch graph"}, or as a {@link #LOAD "load graph"}.
* JPA specifies two distinct ways to apply an {@link jakarta.persistence.EntityGraph} -
* as a {@link #FETCH "fetch graph"} or as a {@link #LOAD "load graph"}.
*
* @author Steve Ebersole
*/
@ -22,7 +27,7 @@ public enum GraphSemantic {
* are not fetched.
* </ul>
*/
FETCH( "javax.persistence.fetchgraph", "jakarta.persistence.fetchgraph" ),
FETCH( HINT_FETCH_GRAPH, HINT_JAVAEE_FETCH_GRAPH ),
/**
* Indicates that an {@link jakarta.persistence.EntityGraph} should be interpreted as a JPA "load graph".
@ -33,23 +38,14 @@ public enum GraphSemantic {
* depending on the mapping of the attribute, instead of forcing {@code FetchType.LAZY}.
* </ul>
*/
LOAD( "javax.persistence.loadgraph", "jakarta.persistence.loadgraph" );
LOAD( HINT_LOAD_GRAPH, HINT_JAVAEE_LOAD_GRAPH );
private final String jakartaHintName;
private final String jpaHintName;
private final String jakartaJpaHintName;
GraphSemantic(String jpaHintName, String jakartaJpaHintName) {
GraphSemantic(String jakartaHintName, String jpaHintName) {
this.jakartaHintName = jakartaHintName;
this.jpaHintName = jpaHintName;
this.jakartaJpaHintName = jakartaJpaHintName;
}
/**
* The hint name that should be used with JPA.
*
* @see jakarta.persistence.Query#setHint(String, Object)
*/
public String getJpaHintName() {
return jpaHintName;
}
/**
@ -57,18 +53,31 @@ public enum GraphSemantic {
*
* @see jakarta.persistence.Query#setHint(String, Object)
*/
public String getJakartaJpaHintName() {
return jakartaJpaHintName;
public String getJakartaHintName() {
return jakartaHintName;
}
public static GraphSemantic fromJpaHintName(String hintName) {
/**
* The hint name that should be used with JPA.
*
* @see org.hibernate.jpa.LegacySpecHints#HINT_JAVAEE_FETCH_GRAPH
* @see org.hibernate.jpa.LegacySpecHints#HINT_JAVAEE_LOAD_GRAPH
*
* @deprecated (since 6.0) Use {@link #getJakartaHintName} instead
*/
@Deprecated
public String getJpaHintName() {
return jpaHintName;
}
public static GraphSemantic fromHintName(String hintName) {
assert hintName != null;
if ( FETCH.getJpaHintName().equals( hintName ) || FETCH.getJakartaJpaHintName().equals( hintName ) ) {
if ( FETCH.getJakartaHintName().equals( hintName ) || FETCH.getJpaHintName().equals( hintName ) ) {
return FETCH;
}
if ( LOAD.getJpaHintName().equalsIgnoreCase( hintName ) || LOAD.getJakartaJpaHintName().equalsIgnoreCase( hintName ) ) {
if ( LOAD.getJakartaHintName().equalsIgnoreCase( hintName ) || LOAD.getJpaHintName().equalsIgnoreCase( hintName ) ) {
return LOAD;
}
@ -77,4 +86,12 @@ public enum GraphSemantic {
"expecting `" + FETCH.jpaHintName + "` or `" + LOAD.jpaHintName + "`."
);
}
/**
* @deprecated (since 6.0) Use {@link #fromHintName} instead
*/
@Deprecated
public static GraphSemantic fromJpaHintName(String hintName) {
return fromHintName( hintName );
}
}

View File

@ -61,7 +61,9 @@ import org.hibernate.event.spi.RefreshEventListener;
import org.hibernate.event.spi.ReplicateEventListener;
import org.hibernate.event.spi.ResolveNaturalIdEventListener;
import org.hibernate.event.spi.SaveOrUpdateEventListener;
import org.hibernate.jpa.LegacySpecHints;
import org.hibernate.jpa.QueryHints;
import org.hibernate.jpa.SpecHints;
import org.hibernate.jpa.internal.util.CacheModeHelper;
import org.hibernate.jpa.internal.util.ConfigurationHelper;
import org.hibernate.jpa.internal.util.LockOptionsHelper;
@ -287,17 +289,19 @@ public final class FastSessionServices {
//Defaults defined by SessionFactory configuration:
final String[] ENTITY_MANAGER_SPECIFIC_PROPERTIES = {
JPA_LOCK_SCOPE,
JAKARTA_LOCK_SCOPE,
JPA_LOCK_TIMEOUT,
JAKARTA_LOCK_TIMEOUT,
SpecHints.HINT_LOCK_SCOPE,
SpecHints.HINT_LOCK_TIMEOUT,
SpecHints.HINT_QUERY_TIMEOUT,
SpecHints.HINT_CACHE_RETRIEVE_MODE,
SpecHints.HINT_CACHE_STORE_MODE,
AvailableSettings.FLUSH_MODE,
JPA_SHARED_CACHE_RETRIEVE_MODE,
JAKARTA_SHARED_CACHE_RETRIEVE_MODE,
JPA_SHARED_CACHE_STORE_MODE,
JAKARTA_SHARED_CACHE_STORE_MODE,
QueryHints.SPEC_HINT_TIMEOUT,
QueryHints.JAKARTA_SPEC_HINT_TIMEOUT
LegacySpecHints.HINT_JAVAEE_LOCK_SCOPE,
LegacySpecHints.HINT_JAVAEE_LOCK_TIMEOUT,
LegacySpecHints.HINT_JAVAEE_CACHE_RETRIEVE_MODE,
LegacySpecHints.HINT_JAVAEE_CACHE_STORE_MODE,
LegacySpecHints.HINT_JAVAEE_QUERY_TIMEOUT
};
final Map<String, Object> properties = sf.getProperties();
for ( String key : ENTITY_MANAGER_SPECIFIC_PROPERTIES ) {

View File

@ -0,0 +1,25 @@
/*
* 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.jpa;
import java.util.Map;
import jakarta.persistence.LockModeType;
/**
* Combined set of Hibernate and Jakarta Persistence hints
*
* @see jakarta.persistence.EntityManager#setProperty(String, Object)
* @see jakarta.persistence.EntityManager#find(Class, Object, Map)
* @see jakarta.persistence.EntityManager#find(Class, Object, LockModeType, Map)
* @see jakarta.persistence.EntityManager#lock(Object, LockModeType, Map)
* @see jakarta.persistence.Query#setHint
*
* @author Steve Ebersole
*/
public interface AvailableHints extends HibernateHints, SpecHints {
}

View File

@ -0,0 +1,144 @@
/*
* 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.jpa;
import org.hibernate.FlushMode;
import org.hibernate.query.Query;
/**
* List of Hibernate-specific (extension) hints available to query,
* load and lock scenarios.
*
* Some hints are only valid for certain scenarios, which is noted on
* each constant's docuementation
*
* @author Steve Ebersole
*/
public interface HibernateHints {
/**
* Hint for specifying a query timeout, in seconds.
*
* @see org.hibernate.query.Query#setTimeout
* @see java.sql.Statement#setQueryTimeout
*/
String HINT_TIMEOUT = "org.hibernate.timeout";
/**
* Hint for specifying that objects loaded into the persistence
* context as a result of a query should be associated with the
* persistence context as read-only.
*
* @see Query#setReadOnly
*/
String HINT_READ_ONLY = "org.hibernate.readOnly";
/**
* Hint for specifying a JDBC fetch size to be applied to the
* JDBC statement.
*
* @see Query#setFetchSize
* @see java.sql.Statement#setFetchSize
*/
String HINT_FETCH_SIZE = "org.hibernate.fetchSize";
/**
* Hint for specifying a database comment to be applied to
* the SQL sent to the database.
*
* @implSpec Not valid for {@link org.hibernate.procedure.ProcedureCall}
* nor {@link jakarta.persistence.StoredProcedureQuery} scenarios
*
* @see Query#setComment
*/
String HINT_COMMENT = "org.hibernate.comment";
/**
* Hint for specifying the {@link org.hibernate.FlushMode}
* to apply to Query execution
*
* @see Query#setHibernateFlushMode
* @see org.hibernate.Session#setHibernateFlushMode
*/
String HINT_FLUSH_MODE = "org.hibernate.flushMode";
/**
* Hint for specifying whether results from a query should
* be stored in the query cache
*
* @see Query#setCacheable
*/
String HINT_CACHEABLE = "org.hibernate.cacheable";
/**
* Hint for specifying the region of the query cache into which
* the results should be stored
*
* @implSpec No effect unless {@link #HINT_CACHEABLE} is set to {@code true}
*
* @see Query#setCacheRegion
*/
String HINT_CACHE_REGION = "org.hibernate.cacheRegion";
/**
* Hint for specifying the {@link org.hibernate.CacheMode} to use
*
* @implSpec No effect unless {@link #HINT_CACHEABLE} is set to {@code true}
*
* @see Query#setCacheMode
*/
String HINT_CACHE_MODE = "org.hibernate.cacheMode";
/**
* Hint to enable/disable the follow-on-locking mechanism provided by
* {@link org.hibernate.dialect.Dialect#useFollowOnLocking(String, org.hibernate.query.spi.QueryOptions)}.
* A value of {@code true} enables follow-on-locking, whereas a value of
* {@code false} disables it. If the value is {@code null}, the
* {@code Dialect}'s default strategy is used.
*
* @since 5.2
*/
String HINT_FOLLOW_ON_LOCKING = "hibernate.query.followOnLocking";
/**
* Hint for specifying the lock-mode to apply to the results from a
* native-query.
*
* While Hibernate supports applying lock-mode to a natove-query, the specification
* requires that {@link jakarta.persistence.Query#setLockMode} throw an
* {@link IllegalStateException} if called for a native query.
*
* Accepts a {@link jakarta.persistence.LockModeType} or a {@link org.hibernate.LockMode}
*/
String HINT_NATIVE_LOCK_MODE = "org.hibernate.lockMode";
/**
* Hint for specifying query spaces to be applied to a NativeQuery.
*
* Passed value can be any of:<ul>
* <li>List of the spaces</li>
* <li>array of the spaces</li>
* <li>String as "whitespace"-separated list of the spaces</li>
* </ul>
*
* Note that the passed space need not match any real spaces/tables in
* the underlying query. This can be used to completely circumvent
* the auto-flush checks as well as any cache invalidation that might
* occur as part of a flush. See {@link org.hibernate.query.SynchronizeableQuery}
* and {@link FlushMode#MANUAL} for more information.
*
* @see org.hibernate.SynchronizeableQuery
* @see #HINT_FLUSH_MODE
*/
String HINT_NATIVE_SPACES = "org.hibernate.query.native.spaces";
/**
* Whether to treat a {@link org.hibernate.procedure.ProcedureCall}
* or {@link jakarta.persistence.StoredProcedureQuery} as a call
* to a function rather than a call to a procedure
*/
String HINT_CALLABLE_FUNCTION = "org.hibernate.callableFunction";
}

View File

@ -41,8 +41,8 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
/**
* {@inheritDoc}
* <p/>
* Note: per-spec, the values passed as {@code properties} override values found in {@code persistence.xml}
*
* @implSpec Per the specification, the values passed as {@code properties} override values found in {@code persistence.xml}
*/
@Override
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
@ -52,9 +52,7 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
log.trace( "Could not obtain matching EntityManagerFactoryBuilder, returning null" );
return null;
}
else {
return builder.build();
}
return builder.build();
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties) {

View File

@ -0,0 +1,59 @@
/*
* 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.jpa;
/**
* Legacy form (`javax.persistence` namespace) of the hints explicitly
* defined by the Jakarta Persistence
*
* @apiNote These are a temporary migration aids for migrating from
* Java Persistence (`javax.persistence` namespace) to Jakarta
* Persistence (`jakarta.persistence` namespace)
*
* @see SpecHints
*
* @deprecated (since 6.0) Use the {@link SpecHints} form instead
*
* @author Steve Ebersole
*/
@Deprecated
public interface LegacySpecHints {
/**
* @see SpecHints#HINT_FETCH_GRAPH
*/
String HINT_JAVAEE_FETCH_GRAPH = "javax.persistence.fetchgraph";
/**
* @see SpecHints#HINT_LOAD_GRAPH
*/
String HINT_JAVAEE_LOAD_GRAPH = "javax.persistence.loadgraph";
/**
* @see SpecHints#HINT_LOCK_TIMEOUT
*/
String HINT_JAVAEE_LOCK_TIMEOUT = "javax.persistence.lock.timeout";
/**
* @see SpecHints#HINT_LOCK_SCOPE
*/
String HINT_JAVAEE_LOCK_SCOPE = "javax.persistence.lock.scope";
/**
* @see SpecHints#HINT_QUERY_TIMEOUT
*/
String HINT_JAVAEE_QUERY_TIMEOUT = "javax.persistence.query.timeout";
/**
* @see SpecHints#HINT_CACHE_RETRIEVE_MODE
*/
String HINT_JAVAEE_CACHE_RETRIEVE_MODE = "javax.persistence.cache.retrieveMode";
/**
* @see SpecHints#HINT_CACHE_STORE_MODE
*/
String HINT_JAVAEE_CACHE_STORE_MODE = "javax.persistence.cache.storeMode";
}

View File

@ -9,170 +9,137 @@ package org.hibernate.jpa;
import java.util.HashSet;
import java.util.Set;
import org.hibernate.graph.GraphSemantic;
import static org.hibernate.annotations.QueryHints.CACHEABLE;
import static org.hibernate.annotations.QueryHints.CACHE_MODE;
import static org.hibernate.annotations.QueryHints.CACHE_REGION;
import static org.hibernate.annotations.QueryHints.COMMENT;
import static org.hibernate.annotations.QueryHints.FETCH_SIZE;
import static org.hibernate.annotations.QueryHints.FLUSH_MODE;
import static org.hibernate.annotations.QueryHints.FOLLOW_ON_LOCKING;
import static org.hibernate.annotations.QueryHints.NATIVE_LOCKMODE;
import static org.hibernate.annotations.QueryHints.NATIVE_SPACES;
import static org.hibernate.annotations.QueryHints.READ_ONLY;
import static org.hibernate.annotations.QueryHints.TIMEOUT_HIBERNATE;
import static org.hibernate.annotations.QueryHints.TIMEOUT_JAKARTA_JPA;
import static org.hibernate.annotations.QueryHints.TIMEOUT_JPA;
/**
* List of all supported hints that may be passed to {@link jakarta.persistence.Query#setHint(String, Object)},
* including those defined by {@link org.hibernate.annotations.QueryHints}, and those defined by the enumerated
* instances of {@link GraphSemantic}.
* List of all supported hints that may be passed to {@link jakarta.persistence.Query#setHint(String, Object)}.
*
* @see org.hibernate.annotations.QueryHints
* @see SpecHints
* @see HibernateHints
*/
public class QueryHints {
/**
* @see SpecHints#HINT_QUERY_TIMEOUT
*/
public static final String JAKARTA_SPEC_HINT_TIMEOUT = SpecHints.HINT_QUERY_TIMEOUT;
/**
* @see HibernateHints#HINT_COMMENT
*/
public static final String HINT_COMMENT = HibernateHints.HINT_COMMENT;
/**
* @see HibernateHints#HINT_FETCH_SIZE
*/
public static final String HINT_FETCH_SIZE = HibernateHints.HINT_FETCH_SIZE;
/**
* @see HibernateHints#HINT_CACHEABLE
*/
public static final String HINT_CACHEABLE = HibernateHints.HINT_CACHEABLE;
/**
* @see HibernateHints#HINT_CACHE_REGION
*/
public static final String HINT_CACHE_REGION = HibernateHints.HINT_CACHE_REGION;
/**
* @see HibernateHints#HINT_CACHE_MODE
*/
public static final String HINT_CACHE_MODE = HibernateHints.HINT_CACHE_MODE;
/**
* @see HibernateHints#HINT_READ_ONLY
*/
public static final String HINT_READONLY = HibernateHints.HINT_READ_ONLY;
/**
* @see HibernateHints#HINT_FLUSH_MODE
*/
public static final String HINT_FLUSH_MODE = HibernateHints.HINT_FLUSH_MODE;
/**
* @see HibernateHints#HINT_NATIVE_LOCK_MODE
*/
public static final String HINT_NATIVE_LOCKMODE = HibernateHints.HINT_NATIVE_LOCK_MODE;
/**
* @see SpecHints#HINT_FETCH_GRAPH
*/
public static final String JAKARTA_HINT_FETCH_GRAPH = SpecHints.HINT_FETCH_GRAPH;
/**
* @see SpecHints#HINT_LOAD_GRAPH
*/
public static final String JAKARTA_HINT_FETCHGRAPH = SpecHints.HINT_FETCH_GRAPH;
/**
* @see SpecHints#HINT_LOAD_GRAPH
*/
public static final String JAKARTA_HINT_LOAD_GRAPH = SpecHints.HINT_LOAD_GRAPH;
/**
* @see SpecHints#HINT_LOAD_GRAPH
*/
public static final String JAKARTA_HINT_LOADGRAPH = SpecHints.HINT_LOAD_GRAPH;
/**
* @see HibernateHints#HINT_FOLLOW_ON_LOCKING
*/
public static final String HINT_FOLLOW_ON_LOCKING = HibernateHints.HINT_FOLLOW_ON_LOCKING;
/**
* @see HibernateHints#HINT_NATIVE_SPACES
*/
public static final String HINT_NATIVE_SPACES = HibernateHints.HINT_NATIVE_SPACES;
/**
* @see LegacySpecHints#HINT_JAVAEE_FETCH_GRAPH
*/
public static final String HINT_FETCHGRAPH = LegacySpecHints.HINT_JAVAEE_FETCH_GRAPH;
/**
* @see LegacySpecHints#HINT_JAVAEE_LOAD_GRAPH
*/
public static final String HINT_LOADGRAPH = LegacySpecHints.HINT_JAVAEE_LOAD_GRAPH;
/**
* The hint key for specifying a query timeout per Hibernate O/RM, which defines the timeout in seconds.
*
* @deprecated use {@link #SPEC_HINT_TIMEOUT} instead
*/
@Deprecated
public static final String HINT_TIMEOUT = TIMEOUT_HIBERNATE;
public static final String HINT_TIMEOUT = HibernateHints.HINT_TIMEOUT;
/**
* The hint key for specifying a query timeout per JPA, which defines the timeout in milliseconds
*/
public static final String SPEC_HINT_TIMEOUT = TIMEOUT_JPA;
/**
* The hint key for specifying a query timeout per JPA, which defines the timeout in milliseconds
*/
public static final String JAKARTA_SPEC_HINT_TIMEOUT = TIMEOUT_JAKARTA_JPA;
/**
* The hint key for specifying a comment which is to be embedded into the SQL sent to the database.
*/
public static final String HINT_COMMENT = COMMENT;
/**
* The hint key for specifying a JDBC fetch size, used when executing the resulting SQL.
*/
public static final String HINT_FETCH_SIZE = FETCH_SIZE;
/**
* The hint key for specifying whether the query results should be cached for the next (cached) execution
* of the "same query".
*/
public static final String HINT_CACHEABLE = CACHEABLE;
/**
* The hint key for specifying the name of the cache region (within Hibernate's query result cache region)
* to use for storing the query results.
*/
public static final String HINT_CACHE_REGION = CACHE_REGION;
/**
* The hint key for specifying that objects loaded into the persistence context as a result of this query
* execution should be associated with the persistence context as read-only.
*/
public static final String HINT_READONLY = READ_ONLY;
/**
* The hint key for specifying the cache mode ({@link org.hibernate.CacheMode}) to be in effect for the
* execution of the hinted query.
*/
public static final String HINT_CACHE_MODE = CACHE_MODE;
/**
* The hint key for specifying the flush mode ({@link org.hibernate.FlushMode}) to be in effect for the
* execution of the hinted query.
*/
public static final String HINT_FLUSH_MODE = FLUSH_MODE;
/**
* The hint key for specifying the lock mode ({@link jakarta.persistence.LockModeType} or
* {@link org.hibernate.LockMode}) to use for execution of a native query.
*/
public static final String HINT_NATIVE_LOCKMODE = NATIVE_LOCKMODE;
/**
* @deprecated Use {@link #JAKARTA_HINT_FETCH_GRAPH} instead
* @see LegacySpecHints#HINT_JAVAEE_QUERY_TIMEOUT
*/
@Deprecated
public static final String HINT_FETCHGRAPH = GraphSemantic.FETCH.getJpaHintName();
/**
* Hint providing a {@link jakarta.persistence.EntityGraph} that should be interpreted as a "fetch graph".
*
* @see GraphSemantic#FETCH
*/
public static final String JAKARTA_HINT_FETCH_GRAPH = GraphSemantic.FETCH.getJakartaJpaHintName();
/**
* @deprecated Use {@link #JAKARTA_HINT_LOAD_GRAPH} instead
*/
@Deprecated
public static final String HINT_LOADGRAPH = GraphSemantic.LOAD.getJpaHintName();
/**
* Hint providing a {@link jakarta.persistence.EntityGraph} that should be interpreted as a "load graph".
*
* @see GraphSemantic#LOAD
*/
public static final String JAKARTA_HINT_LOAD_GRAPH = GraphSemantic.LOAD.getJakartaJpaHintName();
/**
* Hint providing a "fetchgraph" EntityGraph. Attributes explicitly specified as AttributeNodes are treated as
* FetchType.EAGER (via join fetch or subsequent select).
*
* Note: Currently, attributes that are not specified are treated as FetchType.LAZY or FetchType.EAGER depending
* on the attribute's definition in metadata, rather than forcing FetchType.LAZY.
*/
public static final String JAKARTA_HINT_FETCHGRAPH = GraphSemantic.FETCH.getJakartaJpaHintName();
/**
* Hint providing a "loadgraph" EntityGraph. Attributes explicitly specified as AttributeNodes are treated as
* FetchType.EAGER (via join fetch or subsequent select). Attributes that are not specified are treated as
* FetchType.LAZY or FetchType.EAGER depending on the attribute's definition in metadata
*/
public static final String JAKARTA_HINT_LOADGRAPH = GraphSemantic.LOAD.getJakartaJpaHintName();
/**
* The hint key to enable or disable the default follow-on-locking mechanism provided by
* {@link org.hibernate.dialect.Dialect#useFollowOnLocking(String, org.hibernate.query.spi.QueryOptions)}.
*/
public static final String HINT_FOLLOW_ON_LOCKING = FOLLOW_ON_LOCKING;
/**
* Hint key for specifying query spaces to be applied to a native (SQL) query.
*
* @see org.hibernate.annotations.QueryHints#NATIVE_SPACES
*/
public static final String HINT_NATIVE_SPACES = NATIVE_SPACES;
public static final String SPEC_HINT_TIMEOUT = LegacySpecHints.HINT_JAVAEE_QUERY_TIMEOUT;
private static final Set<String> HINTS = buildHintsSet();
private static Set<String> buildHintsSet() {
HashSet<String> hints = new HashSet<>();
hints.add( HINT_TIMEOUT );
hints.add( SPEC_HINT_TIMEOUT );
hints.add( JAKARTA_SPEC_HINT_TIMEOUT );
hints.add( HINT_COMMENT );
hints.add( HINT_FETCH_SIZE );
hints.add( HINT_CACHE_REGION );
hints.add( HINT_CACHEABLE );
hints.add( HINT_READONLY );
hints.add( HINT_CACHE_MODE );
hints.add( HINT_FLUSH_MODE );
hints.add( HINT_NATIVE_LOCKMODE );
hints.add( HINT_FETCHGRAPH );
hints.add( HINT_LOADGRAPH );
hints.add( JAKARTA_HINT_FETCHGRAPH );
hints.add( JAKARTA_HINT_LOADGRAPH );
hints.add( HINT_NATIVE_SPACES );
final HashSet<String> hints = new HashSet<>();
hints.add( HibernateHints.HINT_TIMEOUT );
hints.add( HibernateHints.HINT_READ_ONLY );
hints.add( HibernateHints.HINT_FLUSH_MODE );
hints.add( HibernateHints.HINT_CACHEABLE );
hints.add( HibernateHints.HINT_CACHE_MODE );
hints.add( HibernateHints.HINT_CACHE_REGION );
hints.add( HibernateHints.HINT_FETCH_SIZE );
hints.add( HibernateHints.HINT_COMMENT );
hints.add( HibernateHints.HINT_NATIVE_SPACES );
hints.add( HibernateHints.HINT_NATIVE_LOCK_MODE );
hints.add( SpecHints.HINT_QUERY_TIMEOUT );
hints.add( SpecHints.HINT_FETCH_GRAPH );
hints.add( SpecHints.HINT_LOAD_GRAPH );
hints.add( LegacySpecHints.HINT_JAVAEE_QUERY_TIMEOUT );
hints.add( LegacySpecHints.HINT_JAVAEE_FETCH_GRAPH );
hints.add( LegacySpecHints.HINT_JAVAEE_LOAD_GRAPH );
return java.util.Collections.unmodifiableSet( hints );
}

View File

@ -0,0 +1,86 @@
/*
* 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.jpa;
import java.util.Map;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.graph.GraphSemantic;
import jakarta.persistence.LockModeType;
/**
* The hints explicitly defined by the Jakarta Persistence specification
* which are available for both queries and loading
*
* @see jakarta.persistence.EntityManager#find(Class, Object, Map)
* @see jakarta.persistence.EntityManager#find(Class, Object, LockModeType, Map)
* @see org.hibernate.Session#lock(Object, LockModeType, Map)
* @see jakarta.persistence.Query#setHint
*
* @author Steve Ebersole
*/
public interface SpecHints {
/**
* Hint providing a {@link jakarta.persistence.EntityGraph} which should be
* interpreted as a "fetch graph".
*
* @see GraphSemantic#FETCH
*/
String HINT_FETCH_GRAPH = "jakarta.persistence.fetchgraph";
/**
* Hint providing a {@link jakarta.persistence.EntityGraph} which should be
* interpreted as a "load graph".
*
* @see GraphSemantic#LOAD
*/
String HINT_LOAD_GRAPH = "jakarta.persistence.loadgraph";
/**
* Hint requesting a pessimistic lock timeout (in milliseconds).
*/
String HINT_LOCK_TIMEOUT = "jakarta.persistence.lock.timeout";
/**
* Hint indicating whether to extend pessimistic locking to
* associated tables. Expected to be an instance of
* {@link jakarta.persistence.PessimisticLockScope}
*/
String HINT_LOCK_SCOPE = "jakarta.persistence.lock.scope";
/**
* The Jakarta Persistence defined hint for requesting a timeout
* be applied to a {@link jakarta.persistence.Query} executions.
*
* @implSpec Not valid for load and/or lock operations
*/
String HINT_QUERY_TIMEOUT = "jakarta.persistence.query.timeout";
/**
* Hint specifying how Hibernate should handle retrieving data from
* the second level cache.
*
* @see jakarta.persistence.CacheRetrieveMode
* @see jakarta.persistence.EntityManager#setProperty
* @see jakarta.persistence.Query#setHint
* @see org.hibernate.CacheMode
*/
String HINT_CACHE_RETRIEVE_MODE = "jakarta.persistence.cache.retrieveMode";
/**
* Hint specifying how Hibernate should handle retrieving data from
* the second level cache.
*
* @see jakarta.persistence.CacheStoreMode
* @see jakarta.persistence.EntityManager#setProperty
* @see jakarta.persistence.Query#setHint
* @see org.hibernate.CacheMode
*/
String HINT_CACHE_STORE_MODE = "jakarta.persistence.cache.storeMode";
}

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
*/
/**
* Support for bootstrapping a Jakarta Persistence
* {@link jakarta.persistence.EntityManagerFactory}
*
* @author Steve Ebersole
*/
package org.hibernate.jpa.boot;

View File

@ -6,6 +6,17 @@
*/
/**
* Support for JPA lifecycle callbacks.
* Support for Jakarta Persistence entity listeners.
*
* @see jakarta.persistence.EntityListeners
* @see jakarta.persistence.PrePersist
* @see jakarta.persistence.PreUpdate
* @see jakarta.persistence.PreRemove
* @see jakarta.persistence.PostPersist
* @see jakarta.persistence.PostUpdate
* @see jakarta.persistence.PostRemove
* @see jakarta.persistence.PostLoad
*
* @author Steve Ebersole
*/
package org.hibernate.jpa.event;

View File

@ -12,7 +12,11 @@ package org.hibernate.jpa.spi;
* for that parameter.
*
* @author Gail Badner
*
* @deprecated (since 6.0) Not actually sure what the original intent of this
* was; but it is not used as of 6.0, so slating for removal
*/
@Deprecated
public interface NullTypeBindableParameterRegistration<T> extends ParameterRegistration<T> {
/**

View File

@ -95,6 +95,8 @@ import jakarta.persistence.PersistenceException;
import jakarta.persistence.TemporalType;
import jakarta.persistence.TransactionRequiredException;
import static org.hibernate.jpa.HibernateHints.HINT_CALLABLE_FUNCTION;
/**
* Standard implementation of {@link ProcedureCall}
*
@ -297,7 +299,7 @@ public class ProcedureCallImpl<R>
applyOptions( (NamedQueryMemento) memento );
if ( memento.getHints() != null ) {
final Object callableFunction = memento.getHints().get( QueryHints.CALLABLE_FUNCTION );
final Object callableFunction = memento.getHints().get( HINT_CALLABLE_FUNCTION );
if ( callableFunction != null && Boolean.parseBoolean( callableFunction.toString() ) ) {
final List<Class<?>> resultTypes = new ArrayList<>();
resultSetMapping.visitResultBuilders(

View File

@ -35,7 +35,10 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.internal.EntityManagerMessageLogger;
import org.hibernate.internal.HEMLogging;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.jpa.LegacySpecHints;
import org.hibernate.jpa.QueryHints;
import org.hibernate.jpa.SpecHints;
import org.hibernate.jpa.internal.util.ConfigurationHelper;
import org.hibernate.jpa.internal.util.FlushModeTypeHelper;
import org.hibernate.jpa.internal.util.LockModeTypeHelper;
@ -68,31 +71,32 @@ import static org.hibernate.LockMode.UPGRADE;
import static org.hibernate.LockOptions.NONE;
import static org.hibernate.LockOptions.READ;
import static org.hibernate.LockOptions.WAIT_FOREVER;
import static org.hibernate.annotations.QueryHints.NATIVE_LOCKMODE;
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_LOCK_SCOPE;
import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT;
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE;
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_STORE_MODE;
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
import static org.hibernate.jpa.QueryHints.HINT_CACHEABLE;
import static org.hibernate.jpa.QueryHints.HINT_CACHE_MODE;
import static org.hibernate.jpa.QueryHints.HINT_CACHE_REGION;
import static org.hibernate.jpa.QueryHints.HINT_COMMENT;
import static org.hibernate.jpa.QueryHints.HINT_FETCHGRAPH;
import static org.hibernate.jpa.QueryHints.HINT_FETCH_SIZE;
import static org.hibernate.jpa.QueryHints.HINT_FLUSH_MODE;
import static org.hibernate.jpa.QueryHints.HINT_FOLLOW_ON_LOCKING;
import static org.hibernate.jpa.QueryHints.HINT_LOADGRAPH;
import static org.hibernate.jpa.QueryHints.HINT_NATIVE_SPACES;
import static org.hibernate.jpa.QueryHints.HINT_READONLY;
import static org.hibernate.jpa.QueryHints.HINT_TIMEOUT;
import static org.hibernate.jpa.QueryHints.JAKARTA_HINT_FETCH_GRAPH;
import static org.hibernate.jpa.QueryHints.JAKARTA_HINT_LOAD_GRAPH;
import static org.hibernate.jpa.QueryHints.SPEC_HINT_TIMEOUT;
import static org.hibernate.jpa.HibernateHints.HINT_CACHEABLE;
import static org.hibernate.jpa.HibernateHints.HINT_CACHE_MODE;
import static org.hibernate.jpa.HibernateHints.HINT_CACHE_REGION;
import static org.hibernate.jpa.HibernateHints.HINT_COMMENT;
import static org.hibernate.jpa.HibernateHints.HINT_FETCH_SIZE;
import static org.hibernate.jpa.HibernateHints.HINT_FLUSH_MODE;
import static org.hibernate.jpa.HibernateHints.HINT_FOLLOW_ON_LOCKING;
import static org.hibernate.jpa.HibernateHints.HINT_NATIVE_LOCK_MODE;
import static org.hibernate.jpa.HibernateHints.HINT_NATIVE_SPACES;
import static org.hibernate.jpa.HibernateHints.HINT_READ_ONLY;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_CACHE_RETRIEVE_MODE;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_CACHE_STORE_MODE;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_FETCH_GRAPH;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_LOAD_GRAPH;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_LOCK_SCOPE;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_LOCK_TIMEOUT;
import static org.hibernate.jpa.LegacySpecHints.HINT_JAVAEE_QUERY_TIMEOUT;
import static org.hibernate.jpa.QueryHints.HINT_NATIVE_LOCKMODE;
import static org.hibernate.jpa.SpecHints.HINT_CACHE_RETRIEVE_MODE;
import static org.hibernate.jpa.SpecHints.HINT_CACHE_STORE_MODE;
import static org.hibernate.jpa.SpecHints.HINT_FETCH_GRAPH;
import static org.hibernate.jpa.SpecHints.HINT_LOAD_GRAPH;
import static org.hibernate.jpa.SpecHints.HINT_LOCK_SCOPE;
import static org.hibernate.jpa.SpecHints.HINT_LOCK_TIMEOUT;
import static org.hibernate.jpa.SpecHints.HINT_QUERY_TIMEOUT;
/**
* @author Steve Ebersole
@ -383,24 +387,25 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
@SuppressWarnings("deprecation")
protected void collectHints(Map<String, Object> hints) {
if ( getQueryOptions().getTimeout() != null ) {
hints.put( HINT_TIMEOUT, getQueryOptions().getTimeout() );
hints.put( SPEC_HINT_TIMEOUT, getQueryOptions().getTimeout() * 1000 );
hints.put( HibernateHints.HINT_TIMEOUT, getQueryOptions().getTimeout() );
hints.put( HINT_QUERY_TIMEOUT, getQueryOptions().getTimeout() * 1000 );
hints.put( HINT_JAVAEE_QUERY_TIMEOUT, getQueryOptions().getTimeout() * 1000 );
}
if ( getLockOptions().getTimeOut() != WAIT_FOREVER ) {
hints.put( JPA_LOCK_TIMEOUT, getLockOptions().getTimeOut() );
hints.put( JAKARTA_LOCK_TIMEOUT, getLockOptions().getTimeOut() );
hints.put( HINT_LOCK_TIMEOUT, getLockOptions().getTimeOut() );
hints.put( HINT_JAVAEE_LOCK_TIMEOUT, getLockOptions().getTimeOut() );
}
if ( getLockOptions().getScope() ) {
hints.put( JPA_LOCK_SCOPE, getLockOptions().getScope() );
hints.put( JAKARTA_LOCK_SCOPE, getLockOptions().getScope() );
hints.put( HINT_LOCK_SCOPE, getLockOptions().getScope() );
hints.put( HINT_JAVAEE_LOCK_SCOPE, getLockOptions().getScope() );
}
if ( getLockOptions().hasAliasSpecificLockModes() ) {
for ( Map.Entry<String, LockMode> entry : getLockOptions().getAliasSpecificLocks() ) {
hints.put(
NATIVE_LOCKMODE + '.' + entry.getKey(),
HINT_NATIVE_LOCK_MODE + '.' + entry.getKey(),
entry.getValue().name()
);
}
@ -412,10 +417,10 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
if ( getCacheMode() != null ) {
putIfNotNull( hints, HINT_CACHE_MODE, getCacheMode() );
putIfNotNull( hints, JAKARTA_SHARED_CACHE_RETRIEVE_MODE, getQueryOptions().getCacheRetrieveMode() );
putIfNotNull( hints, JAKARTA_SHARED_CACHE_STORE_MODE, getQueryOptions().getCacheStoreMode() );
putIfNotNull( hints, JPA_SHARED_CACHE_RETRIEVE_MODE, getQueryOptions().getCacheRetrieveMode() );
putIfNotNull( hints, JPA_SHARED_CACHE_STORE_MODE, getQueryOptions().getCacheStoreMode() );
putIfNotNull( hints, HINT_CACHE_RETRIEVE_MODE, getQueryOptions().getCacheRetrieveMode() );
putIfNotNull( hints, HINT_CACHE_STORE_MODE, getQueryOptions().getCacheStoreMode() );
putIfNotNull( hints, HINT_JAVAEE_CACHE_RETRIEVE_MODE, getQueryOptions().getCacheRetrieveMode() );
putIfNotNull( hints, HINT_JAVAEE_CACHE_STORE_MODE, getQueryOptions().getCacheStoreMode() );
}
if ( isCacheable() ) {
@ -424,7 +429,7 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
}
if ( isReadOnly() ) {
hints.put( HINT_READONLY, true );
hints.put( HINT_READ_ONLY, true );
}
}
@ -449,15 +454,23 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
boolean applied = false;
try {
if ( HINT_TIMEOUT.equals( hintName ) ) {
if ( QueryHints.HINT_TIMEOUT.equals( hintName ) ) {
applied = applyTimeoutHint( ConfigurationHelper.getInteger( value ) );
}
else if ( SPEC_HINT_TIMEOUT.equals( hintName ) ) {
else if ( HINT_QUERY_TIMEOUT.equals( hintName )
|| HINT_JAVAEE_QUERY_TIMEOUT.equals( hintName ) ) {
if ( HINT_JAVAEE_QUERY_TIMEOUT.equals( hintName ) ) {
DEPRECATION_LOGGER.deprecatedSetting( HINT_JAVAEE_QUERY_TIMEOUT, HINT_QUERY_TIMEOUT );
}
// convert milliseconds to seconds
int timeout = (int)Math.round( ConfigurationHelper.getInteger( value ).doubleValue() / 1000.0 );
applied = applyTimeoutHint( timeout );
}
else if ( JPA_LOCK_TIMEOUT.equals( hintName ) ) {
else if ( HINT_LOCK_TIMEOUT.equals( hintName )
|| HINT_JAVAEE_LOCK_TIMEOUT.equals( hintName ) ) {
if ( HINT_JAVAEE_LOCK_TIMEOUT.equals( hintName ) ) {
DEPRECATION_LOGGER.deprecatedSetting( HINT_JAVAEE_LOCK_TIMEOUT, HINT_LOCK_TIMEOUT );
}
applied = applyLockTimeoutHint( ConfigurationHelper.getInteger( value ) );
}
else if ( HINT_COMMENT.equals( hintName ) ) {
@ -472,7 +485,7 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
else if ( HINT_CACHE_REGION.equals( hintName ) ) {
applied = applyCacheRegionHint( (String) value );
}
else if ( HINT_READONLY.equals( hintName ) ) {
else if ( HINT_READ_ONLY.equals( hintName ) ) {
applied = applyReadOnlyHint( ConfigurationHelper.getBoolean( value ) );
}
else if ( HINT_FLUSH_MODE.equals( hintName ) ) {
@ -481,28 +494,28 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
else if ( HINT_CACHE_MODE.equals( hintName ) ) {
applied = applyCacheModeHint( ConfigurationHelper.getCacheMode( value ) );
}
else if ( JAKARTA_SHARED_CACHE_RETRIEVE_MODE.equals( hintName ) ) {
else if ( HINT_CACHE_RETRIEVE_MODE.equals( hintName )
|| HINT_JAVAEE_CACHE_RETRIEVE_MODE.equals( hintName ) ) {
if ( HINT_JAVAEE_CACHE_RETRIEVE_MODE.equals( hintName ) ) {
DEPRECATION_LOGGER.deprecatedSetting( HINT_JAVAEE_CACHE_RETRIEVE_MODE, HINT_CACHE_RETRIEVE_MODE );
}
final CacheRetrieveMode retrieveMode = value != null ? CacheRetrieveMode.valueOf( value.toString() ) : null;
applied = applyJpaCacheRetrieveMode( retrieveMode );
}
else if ( JAKARTA_SHARED_CACHE_STORE_MODE.equals( hintName ) ) {
else if ( HINT_CACHE_STORE_MODE.equals( hintName )
|| HINT_JAVAEE_CACHE_STORE_MODE.equals( hintName ) ) {
if ( HINT_JAVAEE_CACHE_STORE_MODE.equals( hintName ) ) {
DEPRECATION_LOGGER.deprecatedSetting( HINT_JAVAEE_CACHE_STORE_MODE, HINT_CACHE_STORE_MODE );
}
final CacheStoreMode storeMode = value != null ? CacheStoreMode.valueOf( value.toString() ) : null;
applied = applyJpaCacheStoreMode( storeMode );
}
else if ( JPA_SHARED_CACHE_RETRIEVE_MODE.equals( hintName ) ) {
final CacheRetrieveMode retrieveMode = value != null ? CacheRetrieveMode.valueOf( value.toString() ) : null;
applied = applyJpaCacheRetrieveMode( retrieveMode );
}
else if ( JPA_SHARED_CACHE_STORE_MODE.equals( hintName ) ) {
final CacheStoreMode storeMode = value != null ? CacheStoreMode.valueOf( value.toString() ) : null;
applied = applyJpaCacheStoreMode( storeMode );
}
else if ( QueryHints.HINT_NATIVE_LOCKMODE.equals( hintName ) ) {
else if ( HINT_NATIVE_LOCKMODE.equals( hintName ) ) {
applied = applyNativeQueryLockMode( value );
}
else if ( hintName.startsWith( NATIVE_LOCKMODE ) ) {
else if ( hintName.startsWith( HINT_NATIVE_LOCK_MODE ) ) {
// extract the alias
final String alias = hintName.substring( NATIVE_LOCKMODE.length() + 1 );
final String alias = hintName.substring( HINT_NATIVE_LOCK_MODE.length() + 1 );
// determine the LockMode
try {
final LockMode lockMode = LockModeTypeHelper.interpretLockMode( value );
@ -514,7 +527,7 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
applied = false;
}
}
else if ( JAKARTA_HINT_FETCH_GRAPH.equals( hintName ) || JAKARTA_HINT_LOAD_GRAPH.equals( hintName ) ) {
else if ( HINT_FETCH_GRAPH.equals( hintName ) || HINT_LOAD_GRAPH.equals( hintName ) ) {
if ( value instanceof RootGraphImplementor ) {
applyEntityGraphQueryHint( hintName, (RootGraphImplementor<?>) value );
}
@ -525,12 +538,12 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
}
applied = true;
}
else if ( HINT_FETCHGRAPH.equals( hintName ) || HINT_LOADGRAPH.equals( hintName ) ) {
if ( HINT_FETCHGRAPH.equals( hintName ) ) {
DEPRECATION_LOGGER.deprecatedSetting( HINT_FETCHGRAPH, JAKARTA_HINT_FETCH_GRAPH );
else if ( HINT_JAVAEE_FETCH_GRAPH.equals( hintName ) || HINT_JAVAEE_LOAD_GRAPH.equals( hintName ) ) {
if ( HINT_JAVAEE_FETCH_GRAPH.equals( hintName ) ) {
DEPRECATION_LOGGER.deprecatedSetting( HINT_JAVAEE_FETCH_GRAPH, HINT_FETCH_GRAPH );
}
else {
DEPRECATION_LOGGER.deprecatedSetting( HINT_FETCHGRAPH, JAKARTA_HINT_FETCH_GRAPH );
DEPRECATION_LOGGER.deprecatedSetting( HINT_JAVAEE_LOAD_GRAPH, HINT_LOAD_GRAPH );
}
if ( value instanceof RootGraphImplementor ) {
@ -543,8 +556,6 @@ public abstract class AbstractQuery<R> implements QueryImplementor<R> {
}
applied = true;
}
else if ( HINT_FOLLOW_ON_LOCKING.equals( hintName ) ) {
applied = applyFollowOnLockingHint( ConfigurationHelper.getBoolean( value ) );
}

View File

@ -15,7 +15,7 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
*/
public class TestNamingStrategy extends PhysicalNamingStrategyStandardImpl {
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier( "TAB_" + name.getText() );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier( "TAB_" + logicalName.getText() );
}
}

View File

@ -13,7 +13,7 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
@SuppressWarnings("serial")
public class DummyNamingStrategy extends PhysicalNamingStrategyStandardImpl {
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return jdbcEnvironment.getIdentifierHelper().toIdentifier( "T" + name.getText() );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return jdbcEnvironment.getIdentifierHelper().toIdentifier( "T" + logicalName.getText() );
}
}

View File

@ -68,8 +68,8 @@ public class NamingStrategyTest extends BaseUnitTestCase {
.applyPhysicalNamingStrategy( new PhysicalNamingStrategyStandardImpl() {
@Override
public Identifier toPhysicalColumnName(
Identifier name, JdbcEnvironment context) {
return new Identifier( name.getText().toUpperCase(), name.isQuoted() );
Identifier logicalName, JdbcEnvironment context) {
return new Identifier( logicalName.getText().toUpperCase(), logicalName.isQuoted() );
}
} )
.build();

View File

@ -55,32 +55,32 @@ public class NamespaceTest {
public static class TestNamingStrategy implements PhysicalNamingStrategy {
@Override
public Identifier toPhysicalCatalogName(
Identifier name, JdbcEnvironment jdbcEnvironment) {
Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return new Identifier( EXPECTED_CATALOG_PHYSICAL_NAME, false );
}
@Override
public Identifier toPhysicalSchemaName(
Identifier name, JdbcEnvironment jdbcEnvironment) {
Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return new Identifier( EXPECTED_SCHEMA_PHYSICAL_NAME, false );
}
@Override
public Identifier toPhysicalTableName(
Identifier name, JdbcEnvironment jdbcEnvironment) {
return name;
Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return logicalName;
}
@Override
public Identifier toPhysicalSequenceName(
Identifier name, JdbcEnvironment jdbcEnvironment) {
Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return null;
}
@Override
public Identifier toPhysicalColumnName(
Identifier name, JdbcEnvironment jdbcEnvironment) {
return name;
Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return logicalName;
}
}
}

View File

@ -7,9 +7,11 @@
//$Id$
package org.hibernate.orm.test.jpa;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityResult;
@ -24,7 +26,13 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.QueryHint;
import jakarta.persistence.SqlResultSetMapping;
import org.hibernate.annotations.QueryHints;
import static org.hibernate.jpa.HibernateHints.HINT_CACHEABLE;
import static org.hibernate.jpa.HibernateHints.HINT_CACHE_MODE;
import static org.hibernate.jpa.HibernateHints.HINT_COMMENT;
import static org.hibernate.jpa.HibernateHints.HINT_FETCH_SIZE;
import static org.hibernate.jpa.HibernateHints.HINT_FLUSH_MODE;
import static org.hibernate.jpa.HibernateHints.HINT_READ_ONLY;
import static org.hibernate.jpa.SpecHints.HINT_QUERY_TIMEOUT;
/**
* @author Gavin King
@ -54,13 +62,13 @@ import org.hibernate.annotations.QueryHints;
query = "select i from Item i",
lockMode = LockModeType.PESSIMISTIC_WRITE,
hints = {
@QueryHint( name = QueryHints.TIMEOUT_JPA, value = "3000" ),
@QueryHint( name = QueryHints.CACHE_MODE, value = "ignore" ),
@QueryHint( name = QueryHints.CACHEABLE, value = "true" ),
@QueryHint( name = QueryHints.READ_ONLY, value = "true" ),
@QueryHint( name = QueryHints.COMMENT, value = "custom static comment" ),
@QueryHint( name = QueryHints.FETCH_SIZE, value = "512" ),
@QueryHint( name = QueryHints.FLUSH_MODE, value = "manual" )
@QueryHint( name = HINT_QUERY_TIMEOUT, value = "3000" ),
@QueryHint( name = HINT_CACHE_MODE, value = "ignore" ),
@QueryHint( name = HINT_CACHEABLE, value = "true" ),
@QueryHint( name = HINT_READ_ONLY, value = "true" ),
@QueryHint( name = HINT_COMMENT, value = "custom static comment" ),
@QueryHint( name = HINT_FETCH_SIZE, value = "512" ),
@QueryHint( name = HINT_FLUSH_MODE, value = "manual" )
}
),
@NamedQuery(name = "query-construct", query = "select new Item(i.name,i.descr) from Item i")

View File

@ -15,7 +15,7 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
*/
public class MyNamingStrategy extends PhysicalNamingStrategyStandardImpl {
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return jdbcEnvironment.getIdentifierHelper().toIdentifier( "tbl_" + name.getText() );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return jdbcEnvironment.getIdentifierHelper().toIdentifier( "tbl_" + logicalName.getText() );
}
}

View File

@ -35,32 +35,32 @@ public class TestNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl i
}
@Override
public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment context) {
return PhysicalNamingStrategyStandardImpl.INSTANCE.toPhysicalCatalogName( name, context );
public Identifier toPhysicalCatalogName(Identifier logicalName, JdbcEnvironment context) {
return PhysicalNamingStrategyStandardImpl.INSTANCE.toPhysicalCatalogName( logicalName, context );
}
@Override
public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return PhysicalNamingStrategyStandardImpl.INSTANCE.toPhysicalSchemaName( name, jdbcEnvironment );
public Identifier toPhysicalSchemaName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return PhysicalNamingStrategyStandardImpl.INSTANCE.toPhysicalSchemaName( logicalName, jdbcEnvironment );
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier( "TAB_" + name.getText() );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier( "TAB_" + logicalName.getText() );
}
@Override
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return PhysicalNamingStrategyStandardImpl.INSTANCE.toPhysicalSequenceName( name, jdbcEnvironment );
public Identifier toPhysicalSequenceName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return PhysicalNamingStrategyStandardImpl.INSTANCE.toPhysicalSequenceName( logicalName, jdbcEnvironment );
}
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
if ( name.getText().startsWith( "PTCN_" ) ) {
return name;
public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
if ( logicalName.getText().startsWith( "PTCN_" ) ) {
return logicalName;
}
else {
return Identifier.toIdentifier( "CN_" + name.getText() );
return Identifier.toIdentifier( "CN_" + logicalName.getText() );
}
}
}

View File

@ -21,17 +21,17 @@ public class PhysicalNamingStrategyImpl extends PhysicalNamingStrategyStandardIm
public static final PhysicalNamingStrategyImpl INSTANCE = new PhysicalNamingStrategyImpl();
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier(makeCleanIdentifier("tbl_" + name.getText()), name.isQuoted());
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return Identifier.toIdentifier(makeCleanIdentifier("tbl_" + logicalName.getText()), logicalName.isQuoted());
}
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
if ( name.getText().equals("DTYPE") ) {
return name;
public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
if ( logicalName.getText().equals("DTYPE") ) {
return logicalName;
}
return Identifier.toIdentifier(makeCleanIdentifier("c_" + name.getText()), name.isQuoted());
return Identifier.toIdentifier(makeCleanIdentifier("c_" + logicalName.getText()), logicalName.isQuoted());
}
private String makeCleanIdentifier(String s) {

View File

@ -72,8 +72,8 @@ public class SynchronizeTableNamingTest {
public static final TestingPhysicalNamingStrategy INSTANCE = new TestingPhysicalNamingStrategy();
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
String baseName = name.render( context.getDialect() );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment context) {
String baseName = logicalName.render( context.getDialect() );
if ( baseName.equals( "table_a" ) ) {
baseName = "tbl_a";
}

View File

@ -9,6 +9,20 @@ package org.hibernate.orm.test.querycache;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.hibernate.SessionFactory;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NaturalId;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@ -17,19 +31,6 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import org.hibernate.SessionFactory;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.QueryHints;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -70,7 +71,7 @@ public class QueryCacheJoinFetchTest {
"select distinct p " +
"from Person p " +
"join fetch p.phones ph", Person.class )
.setHint( QueryHints.CACHEABLE, Boolean.TRUE )
.setHint( HibernateHints.HINT_CACHEABLE, Boolean.TRUE )
.getSingleResult();
} );
@ -87,7 +88,7 @@ public class QueryCacheJoinFetchTest {
"select distinct p " +
"from Person p " +
"join fetch p.phones ph", Person.class )
.setHint( QueryHints.CACHEABLE, Boolean.TRUE )
.setHint( HibernateHints.HINT_CACHEABLE, Boolean.TRUE )
.getSingleResult();
} );

View File

@ -16,8 +16,8 @@ public class TestingNamingStrategy extends PhysicalNamingStrategyStandardImpl {
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return jdbcEnvironment.getIdentifierHelper().toIdentifier( applyPrefix( name.getText() ) );
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return jdbcEnvironment.getIdentifierHelper().toIdentifier( applyPrefix( logicalName.getText() ) );
}
private String determineUniquePrefix() {

View File

@ -9,13 +9,15 @@ package org.hibernate.test.procedure;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.annotations.NamedNativeQuery;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityResult;
import jakarta.persistence.FieldResult;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.NamedStoredProcedureQueries;
import jakarta.persistence.NamedStoredProcedureQuery;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderColumn;
@ -27,8 +29,7 @@ import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.Version;
import org.hibernate.annotations.NamedNativeQuery;
import org.hibernate.annotations.QueryHints;
import static org.hibernate.jpa.HibernateHints.HINT_CALLABLE_FUNCTION;
/**
* @author Vlad Mihalcea
@ -52,7 +53,7 @@ import org.hibernate.annotations.QueryHints;
parameters = {
@StoredProcedureParameter(type = Long.class)
},
hints = @QueryHint(name = QueryHints.CALLABLE_FUNCTION, value = "true")
hints = @QueryHint(name = HINT_CALLABLE_FUNCTION, value = "true")
)
@SqlResultSetMappings({
@SqlResultSetMapping(