Skip to content

Commit

Permalink
HHH-12424 - Fix unintended binary compatibility breaks between 5.1 an…
Browse files Browse the repository at this point in the history
…d 5.3
  • Loading branch information
sebersole committed Mar 22, 2018
1 parent c22540a commit bf0741c
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 30 deletions.
Expand Up @@ -17,7 +17,7 @@
* @deprecated (since 5.2) use {@link CommonQueryContract} instead.
*/
@Deprecated
public interface BasicQueryContract {
public interface BasicQueryContract<T extends BasicQueryContract> {
/**
* (Re)set the current FlushMode in effect for this query.
*
Expand Down Expand Up @@ -55,7 +55,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
*
* @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
Expand All @@ -80,7 +80,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
*
* @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
Expand All @@ -105,7 +105,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
*
* @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
Expand All @@ -127,7 +127,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
*
* @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
Expand All @@ -152,7 +152,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
*
* @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
Expand All @@ -178,7 +178,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
*
* @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
Expand Down Expand Up @@ -224,7 +224,7 @@ default CommonQueryContract setFlushMode(FlushMode flushMode) {
* 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
*/
CommonQueryContract setReadOnly(boolean readOnly);
T setReadOnly(boolean readOnly);

/**
* Return the Hibernate types of the query results.
Expand Down
24 changes: 12 additions & 12 deletions hibernate-core/src/main/java/org/hibernate/SQLQuery.java
Expand Up @@ -65,7 +65,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @return this, for method chaining
*/
NativeQuery<T> setResultSetMapping(String name);
SQLQuery<T> setResultSetMapping(String name);

/**
* Is this native-SQL query known to be callable?
Expand All @@ -90,7 +90,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @return {@code this}, for method chaining
*/
NativeQuery<T> addScalar(String columnAlias);
SQLQuery<T> addScalar(String columnAlias);

/**
* Declare a scalar query result.
Expand All @@ -102,7 +102,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand Down Expand Up @@ -138,7 +138,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @return {@code this}, for method chaining
*/
NativeQuery<T> addEntity(String entityName);
SQLQuery<T> addEntity(String entityName);

/**
* Declare a "root" entity.
Expand All @@ -148,7 +148,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand All @@ -159,7 +159,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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
Expand All @@ -169,7 +169,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @return {@code this}, for method chaining
*/
NativeQuery<T> addEntity(Class entityType);
SQLQuery<T> addEntity(Class entityType);

/**
* Declare a "root" entity.
Expand All @@ -179,7 +179,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand All @@ -190,7 +190,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand All @@ -214,7 +214,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand All @@ -228,7 +228,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand All @@ -239,7 +239,7 @@ public interface SQLQuery<T> extends Query<T>, SynchronizeableQuery<T> {
*
* @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.
Expand Down
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate;

import java.io.Closeable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Blob;
Expand All @@ -30,7 +31,7 @@
*
* @author Gavin King
*/
public interface ScrollableResults extends AutoCloseable {
public interface ScrollableResults extends AutoCloseable, Closeable {

/**
* Release resources immediately.
Expand Down
7 changes: 5 additions & 2 deletions hibernate-core/src/main/java/org/hibernate/Session.java
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate;

import java.io.Closeable;
import java.io.Serializable;
import java.sql.Connection;
import javax.persistence.EntityManager;
Expand Down Expand Up @@ -80,7 +81,7 @@
* @author Gavin King
* @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.
*
Expand Down Expand Up @@ -681,8 +682,10 @@ public interface Session extends SharedSessionContract, EntityManager, Hibernate
* @param queryString a Hibernate query fragment.
*
* @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
Expand Down
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate;

import java.io.Closeable;
import java.io.Serializable;
import java.sql.Connection;

Expand All @@ -25,7 +26,7 @@
*
* @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.
*/
Expand Down
4 changes: 4 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/cfg/Settings.java
Expand Up @@ -207,6 +207,10 @@ public boolean isJtaTrackByThread() {
return sessionFactoryOptions.isJtaTrackByThread();
}

public boolean isStrictJPAQLCompliance() {
return sessionFactoryOptions.isStrictJpaQueryLanguageCompliance();
}

public Map getQuerySubstitutions() {
return sessionFactoryOptions.getQuerySubstitutions();
}
Expand Down
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.engine;

import java.io.Closeable;
import java.util.Iterator;

import org.hibernate.JDBCException;
Expand All @@ -18,7 +19,7 @@
*
* @author Gavin King
*/
public interface HibernateIterator extends Iterator, AutoCloseable {
public interface HibernateIterator extends Iterator, AutoCloseable, Closeable {
/**
* Close the Hibernate query result iterator
*
Expand Down
Expand Up @@ -38,6 +38,7 @@
import org.hibernate.LockOptions;
import org.hibernate.MultiIdentifierLoadAccess;
import org.hibernate.NaturalIdLoadAccess;
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.ScrollMode;
import org.hibernate.Session;
Expand Down Expand Up @@ -953,7 +954,7 @@ public LockMode getCurrentLockMode(Object object) {
}

@Override
public org.hibernate.query.Query createFilter(Object collection, String queryString) {
public Query createFilter(Object collection, String queryString) {
return delegate.createFilter( collection, queryString );
}

Expand Down
Expand Up @@ -13,6 +13,7 @@
import javax.persistence.metamodel.EntityType;

import org.hibernate.Metamodel;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;

/**
Expand Down Expand Up @@ -50,6 +51,22 @@ default SessionFactoryImplementor getSessionFactory() {
@Override
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
*
Expand Down

0 comments on commit bf0741c

Please sign in to comment.