move getLockMode() up to SelectionQuery

squash some warnings in the query APIs
This commit is contained in:
Gavin King 2022-11-09 20:04:34 +01:00
parent c966acf178
commit 7bcbfdcc12
6 changed files with 32 additions and 17 deletions

View File

@ -109,7 +109,7 @@ public interface MutationQuery extends CommonQueryContract {
MutationQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
@Override
MutationQuery setParameterList(String name, Collection values);
MutationQuery setParameterList(String name, @SuppressWarnings("rawtypes") Collection values);
@Override
<P> MutationQuery setParameterList(String name, Collection<? extends P> values, Class<P> javaType);
@ -127,7 +127,7 @@ public interface MutationQuery extends CommonQueryContract {
<P> MutationQuery setParameterList(String name, P[] values, BindableType<P> type);
@Override
MutationQuery setParameterList(int position, Collection values);
MutationQuery setParameterList(int position, @SuppressWarnings("rawtypes") Collection values);
@Override
<P> MutationQuery setParameterList(int position, Collection<? extends P> values, Class<P> javaType);

View File

@ -33,7 +33,7 @@ import org.hibernate.type.BasicTypeReference;
/**
* Represents a native (SQL) query.
*
* <p>
* Allows the user to define certain aspects about its execution, such as:<ul>
* <li>
* result-set value mapping (see below)
@ -109,7 +109,7 @@ public interface NativeQuery<T> extends Query<T>, SynchronizeableQuery {
/**
* Declare a scalar query result using the specified result type.
*
* <p>
* Hibernate will implicitly determine an appropriate conversion, if
* it can. Otherwise an exception will be thrown
*
@ -205,7 +205,7 @@ public interface NativeQuery<T> extends Query<T>, SynchronizeableQuery {
* Defines a result based on a specified attribute. Differs from adding a scalar in that
* any conversions or other semantics defined on the attribute are automatically applied
* to the mapping.
*
* <p>
* This form accepts the JPA Attribute mapping describing the attribute
*
* @return {@code this}, for method chaining
@ -355,7 +355,7 @@ public interface NativeQuery<T> extends Query<T>, SynchronizeableQuery {
/**
* Simple unification interface for all returns from the various `#addXYZ` methods .
* Allows control over the "shape" of that particular part of the fetch graph.
*
* <p>
* Some GraphNodes can be query results, while others simply describe a part
* of one of the results.
*/

View File

@ -803,9 +803,7 @@ public interface Query<R> extends SelectionQuery<R>, MutationQuery, TypedQuery<R
/**
* Bind multiple arguments to the query parameter represented by the
* given {@link QueryParameter}, inferring the {@link BindableType}.
*
* Bind multiple arguments to a named query parameter.
* <p/>
* <p>
* The "type mapping" for the binding is inferred from the type of
* the first collection element
*

View File

@ -65,7 +65,7 @@ public interface SelectionQuery<R> extends CommonQueryContract {
/**
* Returns scrollable access to the query results.
*
* <p>
* This form calls {@link #scroll(ScrollMode)} using {@link Dialect#defaultScrollMode()}
*
* @apiNote The exact behavior of this method depends somewhat
@ -170,7 +170,7 @@ public interface SelectionQuery<R> extends CommonQueryContract {
* Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC
* query via {@link java.sql.Statement#setFetchSize(int)}. As defined b y JDBC, this value is a hint to the
* driver to indicate how many rows to fetch from the database when more rows are needed.
*
* <p>
* NOTE : JDBC expressly defines this value as a hint. It may or may not have any effect on the actual
* query execution and ResultSet processing depending on the driver.
*
@ -222,11 +222,11 @@ public interface SelectionQuery<R> extends CommonQueryContract {
* Read-only entities are not dirty-checked and snapshots of persistent
* state are not maintained. Read-only entities can be modified, but
* changes are not persisted.
*
* <p>
* When a proxy is initialized, the loaded entity will have the same
* read-only/modifiable setting as the uninitialized
* proxy has, regardless of the session's current setting.
*
* <p>
* The read-only/modifiable setting has no impact on entities/proxies
* returned by the query that existed in the session beforeQuery the query was executed.
*
@ -329,6 +329,13 @@ public interface SelectionQuery<R> extends CommonQueryContract {
*/
LockOptions getLockOptions();
/**
* Get the root {@link LockModeType} for the query
*
* @see #getHibernateLockMode()
*/
LockModeType getLockMode();
/**
* Specify the root {@link LockModeType} for the query
*
@ -338,11 +345,15 @@ public interface SelectionQuery<R> extends CommonQueryContract {
/**
* Get the root {@link LockMode} for the query
*
* @see #getLockMode()
*/
LockMode getHibernateLockMode();
/**
* Specify the root {@link LockMode} for the query
*
* @see #setLockMode(LockModeType)
*/
SelectionQuery<R> setHibernateLockMode(LockMode lockMode);
@ -419,7 +430,7 @@ public interface SelectionQuery<R> extends CommonQueryContract {
SelectionQuery<R> setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
@Override
SelectionQuery<R> setParameterList(String name, Collection values);
SelectionQuery<R> setParameterList(String name, @SuppressWarnings("rawtypes") Collection values);
@Override
<P> SelectionQuery<R> setParameterList(String name, Collection<? extends P> values, Class<P> javaType);

View File

@ -13,12 +13,13 @@ import org.hibernate.MappingException;
/**
* A unifying interface for queries which can define tables (query spaces) to synchronize on.
*
* <p>
* These query spaces affect the process of auto-flushing by determining which entities will be
* processed by auto-flush based on the table to which those entities are mapped and which are
* determined to have pending state changes.
*
* In a similar manner, these query spaces also affect how query result caching can recognize invalidated results.
* <p>
* In a similar manner, these query spaces also affect how query result caching can recognize
* invalidated results.
*
* @author Steve Ebersole
*/

View File

@ -565,6 +565,11 @@ public abstract class AbstractSelectionQuery<R>
return getQueryOptions().getLockOptions();
}
@Override
public LockModeType getLockMode() {
return LockModeTypeHelper.getLockModeType( getHibernateLockMode() );
}
/**
* Specify the root LockModeType for the query
*