HHH-12424 - Fix unintended binary compatibility breaks between 5.1 and 5.3

This commit is contained in:
Steve Ebersole 2018-03-22 11:57:39 -05:00
parent c22540ab65
commit bf0741caf4
12 changed files with 117 additions and 30 deletions

View File

@ -17,7 +17,7 @@ import org.hibernate.type.Type;
* @deprecated (since 5.2) use {@link CommonQueryContract} instead. * @deprecated (since 5.2) use {@link CommonQueryContract} instead.
*/ */
@Deprecated @Deprecated
public interface BasicQueryContract { public interface BasicQueryContract<T extends BasicQueryContract> {
/** /**
* (Re)set the current FlushMode in effect for this query. * (Re)set the current FlushMode in effect for this query.
* *
@ -55,7 +55,7 @@ public interface BasicQueryContract {
* *
* @see #getHibernateFlushMode() * @see #getHibernateFlushMode()
*/ */
CommonQueryContract setHibernateFlushMode(FlushMode flushMode); T setHibernateFlushMode(FlushMode flushMode);
/** /**
* Obtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session * Obtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session
@ -80,7 +80,7 @@ public interface BasicQueryContract {
* *
* @see #getCacheMode() * @see #getCacheMode()
*/ */
CommonQueryContract setCacheMode(CacheMode cacheMode); T setCacheMode(CacheMode cacheMode);
/** /**
* Are the results of this query eligible for second level query caching? This is different that second level * Are the results of this query eligible for second level query caching? This is different that second level
@ -105,7 +105,7 @@ public interface BasicQueryContract {
* *
* @see #isCacheable * @see #isCacheable
*/ */
CommonQueryContract setCacheable(boolean cacheable); T setCacheable(boolean cacheable);
/** /**
* Obtain the name of the second level query cache region in which query results will be stored (if they are * Obtain the name of the second level query cache region in which query results will be stored (if they are
@ -127,7 +127,7 @@ public interface BasicQueryContract {
* *
* @see #getCacheRegion() * @see #getCacheRegion()
*/ */
CommonQueryContract setCacheRegion(String cacheRegion); T setCacheRegion(String cacheRegion);
/** /**
* Obtain the query timeout <b>in seconds</b>. This value is eventually passed along to the JDBC query via * Obtain the query timeout <b>in seconds</b>. This value is eventually passed along to the JDBC query via
@ -152,7 +152,7 @@ public interface BasicQueryContract {
* *
* @see #getTimeout() * @see #getTimeout()
*/ */
CommonQueryContract setTimeout(int timeout); T setTimeout(int timeout);
/** /**
* Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC * Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC
@ -178,7 +178,7 @@ public interface BasicQueryContract {
* *
* @see #getFetchSize() * @see #getFetchSize()
*/ */
CommonQueryContract setFetchSize(int fetchSize); T setFetchSize(int fetchSize);
/** /**
* Should entities and proxies loaded by this Query be put in read-only mode? If the * Should entities and proxies loaded by this Query be put in read-only mode? If the
@ -224,7 +224,7 @@ public interface BasicQueryContract {
* are to be put in read-only mode; {@code false} indicates that entities and proxies * are to be put in read-only mode; {@code false} indicates that entities and proxies
* loaded by the query will be put in modifiable mode * loaded by the query will be put in modifiable mode
*/ */
CommonQueryContract setReadOnly(boolean readOnly); T setReadOnly(boolean readOnly);
/** /**
* Return the Hibernate types of the query results. * Return the Hibernate types of the query results.

View File

@ -65,7 +65,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return this, for method chaining * @return this, for method chaining
*/ */
NativeQuery<T> setResultSetMapping(String name); SQLQuery<T> setResultSetMapping(String name);
/** /**
* Is this native-SQL query known to be callable? * Is this native-SQL query known to be callable?
@ -90,7 +90,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addScalar(String columnAlias); SQLQuery<T> addScalar(String columnAlias);
/** /**
* Declare a scalar query result. * Declare a scalar query result.
@ -102,7 +102,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addScalar(String columnAlias, Type type); SQLQuery<T> addScalar(String columnAlias, Type type);
/** /**
* Add a new root return mapping, returning a {@link NativeQuery.RootReturn} to allow further definition. * Add a new root return mapping, returning a {@link NativeQuery.RootReturn} to allow further definition.
@ -138,7 +138,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addEntity(String entityName); SQLQuery<T> addEntity(String entityName);
/** /**
* Declare a "root" entity. * Declare a "root" entity.
@ -148,7 +148,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addEntity(String tableAlias, String entityName); SQLQuery<T> addEntity(String tableAlias, String entityName);
/** /**
* Declare a "root" entity, specifying a lock mode. * Declare a "root" entity, specifying a lock mode.
@ -159,7 +159,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addEntity(String tableAlias, String entityName, LockMode lockMode); SQLQuery<T> addEntity(String tableAlias, String entityName, LockMode lockMode);
/** /**
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the * Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the
@ -169,7 +169,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addEntity(Class entityType); SQLQuery<T> addEntity(Class entityType);
/** /**
* Declare a "root" entity. * Declare a "root" entity.
@ -179,7 +179,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addEntity(String tableAlias, Class entityType); SQLQuery<T> addEntity(String tableAlias, Class entityType);
/** /**
* Declare a "root" entity, specifying a lock mode. * Declare a "root" entity, specifying a lock mode.
@ -190,7 +190,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addEntity(String tableAlias, Class entityClass, LockMode lockMode); SQLQuery<T> addEntity(String tableAlias, Class entityClass, LockMode lockMode);
/** /**
* Declare a join fetch result. * Declare a join fetch result.
@ -214,7 +214,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addJoin(String tableAlias, String path); SQLQuery<T> addJoin(String tableAlias, String path);
/** /**
* Declare a join fetch result. * Declare a join fetch result.
@ -228,7 +228,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @since 3.6 * @since 3.6
*/ */
NativeQuery<T> addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName); SQLQuery<T> addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
/** /**
* Declare a join fetch result, specifying a lock mode. * Declare a join fetch result, specifying a lock mode.
@ -239,7 +239,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
NativeQuery<T> addJoin(String tableAlias, String path, LockMode lockMode); SQLQuery<T> addJoin(String tableAlias, String path, LockMode lockMode);
/** /**
* Allows access to further control how properties within a root or join fetch are mapped back from the result set. * Allows access to further control how properties within a root or join fetch are mapped back from the result set.

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate; package org.hibernate;
import java.io.Closeable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.sql.Blob; import java.sql.Blob;
@ -30,7 +31,7 @@ import org.hibernate.type.Type;
* *
* @author Gavin King * @author Gavin King
*/ */
public interface ScrollableResults extends AutoCloseable { public interface ScrollableResults extends AutoCloseable, Closeable {
/** /**
* Release resources immediately. * Release resources immediately.

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate; package org.hibernate;
import java.io.Closeable;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Connection; import java.sql.Connection;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -80,7 +81,7 @@ import org.hibernate.stat.SessionStatistics;
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface Session extends SharedSessionContract, EntityManager, HibernateEntityManager, AutoCloseable { public interface Session extends SharedSessionContract, EntityManager, HibernateEntityManager, AutoCloseable, Closeable {
/** /**
* Obtain a {@link Session} builder with the ability to grab certain information from this session. * Obtain a {@link Session} builder with the ability to grab certain information from this session.
* *
@ -681,8 +682,10 @@ public interface Session extends SharedSessionContract, EntityManager, Hibernate
* @param queryString a Hibernate query fragment. * @param queryString a Hibernate query fragment.
* *
* @return The query instance for manipulation and execution * @return The query instance for manipulation and execution
*
* @deprecated (since 5.3)
*/ */
org.hibernate.query.Query createFilter(Object collection, String queryString); org.hibernate.Query createFilter(Object collection, String queryString);
/** /**
* Completely clear the session. Evict all loaded instances and cancel all pending * Completely clear the session. Evict all loaded instances and cancel all pending

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate; package org.hibernate;
import java.io.Closeable;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Connection; import java.sql.Connection;
@ -25,7 +26,7 @@ import java.sql.Connection;
* *
* @author Gavin King * @author Gavin King
*/ */
public interface StatelessSession extends SharedSessionContract, AutoCloseable { public interface StatelessSession extends SharedSessionContract, AutoCloseable, Closeable {
/** /**
* Close the stateless session and release the JDBC connection. * Close the stateless session and release the JDBC connection.
*/ */

View File

@ -207,6 +207,10 @@ public final class Settings {
return sessionFactoryOptions.isJtaTrackByThread(); return sessionFactoryOptions.isJtaTrackByThread();
} }
public boolean isStrictJPAQLCompliance() {
return sessionFactoryOptions.isStrictJpaQueryLanguageCompliance();
}
public Map getQuerySubstitutions() { public Map getQuerySubstitutions() {
return sessionFactoryOptions.getQuerySubstitutions(); return sessionFactoryOptions.getQuerySubstitutions();
} }

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.engine; package org.hibernate.engine;
import java.io.Closeable;
import java.util.Iterator; import java.util.Iterator;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
@ -18,7 +19,7 @@ import org.hibernate.JDBCException;
* *
* @author Gavin King * @author Gavin King
*/ */
public interface HibernateIterator extends Iterator, AutoCloseable { public interface HibernateIterator extends Iterator, AutoCloseable, Closeable {
/** /**
* Close the Hibernate query result iterator * Close the Hibernate query result iterator
* *

View File

@ -38,6 +38,7 @@ import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MultiIdentifierLoadAccess; import org.hibernate.MultiIdentifierLoadAccess;
import org.hibernate.NaturalIdLoadAccess; import org.hibernate.NaturalIdLoadAccess;
import org.hibernate.Query;
import org.hibernate.ReplicationMode; import org.hibernate.ReplicationMode;
import org.hibernate.ScrollMode; import org.hibernate.ScrollMode;
import org.hibernate.Session; import org.hibernate.Session;
@ -953,7 +954,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
} }
@Override @Override
public org.hibernate.query.Query createFilter(Object collection, String queryString) { public Query createFilter(Object collection, String queryString) {
return delegate.createFilter( collection, queryString ); return delegate.createFilter( collection, queryString );
} }

View File

@ -13,6 +13,7 @@ import javax.persistence.EntityManagerFactory;
import javax.persistence.metamodel.EntityType; import javax.persistence.metamodel.EntityType;
import org.hibernate.Metamodel; import org.hibernate.Metamodel;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
/** /**
@ -50,6 +51,22 @@ public interface HibernateEntityManagerFactory extends EntityManagerFactory, Ser
@Override @Override
Metamodel getMetamodel(); Metamodel getMetamodel();
/**
* Returns the name of the factory. The name is either can be specified via the property <i>hibernate.ejb.entitymanager_factory_name</i>.
* If the property is not set the persistence unit name is used. If persistence unit name is not available, a unique
* name will be generated.
*
* @return the name of the factory.
*
* @deprecated - no longer necessary. all references can be directly replaced with
* calls to {@link SessionFactoryOptions#getSessionFactoryName()}
* via {@link #getSessionFactory()} -> {@link SessionFactoryImplementor#getSessionFactoryOptions()}
*/
@Deprecated
default String getEntityManagerFactoryName() {
return (String) getProperties().get( AvailableSettings.ENTITY_MANAGER_FACTORY_NAME );
}
/** /**
* Find an entity type by name * Find an entity type by name
* *

View File

@ -10,6 +10,7 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.Type; import org.hibernate.type.Type;
@ -116,12 +117,24 @@ public interface ClassMetadata {
// stuff that is tuplizer-centric, but is passed a session ~~~~~~~~~~~~~~~~ // stuff that is tuplizer-centric, but is passed a session ~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
* Return the values of the mapped properties of the object
*
* @deprecated (since 5.3) Use the form accepting SharedSessionContractImplementor
* instead
*/
@Deprecated
@SuppressWarnings({"UnusedDeclaration"})
default Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session)
throws HibernateException {
return getPropertyValuesToInsert( entity, mergeMap, (SharedSessionContractImplementor) session );
}
/** /**
* Return the values of the mapped properties of the object * Return the values of the mapped properties of the object
*/ */
@SuppressWarnings( {"UnusedDeclaration"}) @SuppressWarnings( {"UnusedDeclaration"})
Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SharedSessionContractImplementor session) Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SharedSessionContractImplementor session) throws HibernateException;
throws HibernateException;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -133,6 +146,22 @@ public interface ClassMetadata {
*/ */
Class getMappedClass(); Class getMappedClass();
/**
* Create a class instance initialized with the given identifier
*
* @param id The identifier value to use (may be null to represent no value)
* @param session The session from which the request originated.
*
* @return The instantiated entity.
*
* @deprecated (since 5.3) Use the form accepting SharedSessionContractImplementor
* instead
*/
@Deprecated
default Object instantiate(Serializable id, SessionImplementor session) {
return instantiate( id, (SharedSessionContractImplementor) session );
}
/** /**
* Create a class instance initialized with the given identifier * Create a class instance initialized with the given identifier
* *
@ -176,6 +205,21 @@ public interface ClassMetadata {
@SuppressWarnings( {"JavaDoc"}) @SuppressWarnings( {"JavaDoc"})
Serializable getIdentifier(Object object) throws HibernateException; Serializable getIdentifier(Object object) throws HibernateException;
/**
* Get the identifier of an instance (throw an exception if no identifier property)
*
* @param entity The entity for which to get the identifier
* @param session The session from which the request originated
*
* @return The identifier
*
* @deprecated Use {@link #getIdentifier(Object, SharedSessionContractImplementor)} instead
*/
@Deprecated
default Serializable getIdentifier(Object entity, SessionImplementor session) {
return getIdentifier( entity, (SharedSessionContractImplementor) session );
}
/** /**
* Get the identifier of an instance (throw an exception if no identifier property) * Get the identifier of an instance (throw an exception if no identifier property)
* *
@ -186,6 +230,20 @@ public interface ClassMetadata {
*/ */
Serializable getIdentifier(Object entity, SharedSessionContractImplementor session); Serializable getIdentifier(Object entity, SharedSessionContractImplementor session);
/**
* Inject the identifier value into the given entity.
*
* @param entity The entity to inject with the identifier value.
* @param id The value to be injected as the identifier.
* @param session The session from which is requests originates
*
* @deprecated Use {@link #setIdentifier(Object, Serializable, SharedSessionContractImplementor)} instead
*/
@Deprecated
default void setIdentifier(Object entity, Serializable id, SessionImplementor session) {
setIdentifier( entity, id, (SharedSessionContractImplementor) session );
}
/** /**
* Inject the identifier value into the given entity. * Inject the identifier value into the given entity.
* *

View File

@ -14,13 +14,14 @@ import javax.persistence.StoredProcedureQuery;
import org.hibernate.BasicQueryContract; import org.hibernate.BasicQueryContract;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.SynchronizeableQuery; import org.hibernate.SynchronizeableQuery;
import org.hibernate.query.CommonQueryContract;
/** /**
* Defines support for executing database stored procedures and functions * Defines support for executing database stored procedures and functions
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface ProcedureCall extends BasicQueryContract, SynchronizeableQuery, StoredProcedureQuery { public interface ProcedureCall extends BasicQueryContract<CommonQueryContract>, SynchronizeableQuery, StoredProcedureQuery {
@Override @Override
ProcedureCall addSynchronizedQuerySpace(String querySpace); ProcedureCall addSynchronizedQuerySpace(String querySpace);

View File

@ -14,5 +14,5 @@ package org.hibernate.query;
* @author Steve Ebersole * @author Steve Ebersole
* @author Gavin King * @author Gavin King
*/ */
public interface CommonQueryContract extends org.hibernate.BasicQueryContract { public interface CommonQueryContract extends org.hibernate.BasicQueryContract<CommonQueryContract> {
} }