Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id 'biz.aQute.bnd' version '7.1.0' apply false

id "com.diffplug.spotless" version "7.0.4"
id 'org.checkerframework' version '0.6.56'
id 'org.checkerframework' version '0.6.61'
id 'org.hibernate.orm.build.jdks'

id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
Expand Down
34 changes: 22 additions & 12 deletions checkerstubs/jakarta.persistence.astub
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package jakarta.persistence;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;

public interface AttributeConverter<X,Y> {
public @Nullable Y convertToDatabaseColumn(@Nullable X attribute);
Expand All @@ -20,9 +21,10 @@ public interface EntityManagerFactory extends AutoCloseable {
public interface EntityTransaction {
@Nullable Integer getTimeout();
}
public interface Parameter {
public @Nullable String getName();
public @Nullable Integer getPosition();
public interface Parameter<T> {
@Nullable String getName();
@Nullable Integer getPosition();
@Nullable Class<T> getParameterType();
}
public interface PersistenceUnitUtil extends PersistenceUtil {
public @Nullable Object getIdentifier(Object entity);
Expand Down Expand Up @@ -86,9 +88,9 @@ public interface CommonAbstractCriteria {
}
public interface AbstractQuery<T> extends CommonAbstractCriteria {
AbstractQuery<T> where(@Nullable Expression<Boolean> restriction);
AbstractQuery<T> where(@Nullable Predicate... restrictions);
AbstractQuery<T> where(Predicate @Nullable... restrictions);
AbstractQuery<T> having(@Nullable Expression<Boolean> restriction);
AbstractQuery<T> having(@Nullable Predicate... restrictions);
AbstractQuery<T> having(Predicate @Nullable... restrictions);
@Nullable Selection<T> getSelection();
@Nullable Predicate getGroupRestriction();
}
Expand All @@ -99,12 +101,18 @@ public interface CriteriaUpdate<T> extends CommonAbstractCriteria {
}
public interface Subquery<T> extends AbstractQuery<T>, Expression<T> {
Subquery<T> where(@Nullable Expression<Boolean> restriction);
Subquery<T> where(@Nullable Predicate... restrictions);
Subquery<T> where(Predicate @Nullable... restrictions);
Subquery<T> having(@Nullable Expression<Boolean> restriction);
Subquery<T> having(@Nullable Predicate... restrictions);
Subquery<T> having(Predicate @Nullable... restrictions);
@Nullable Expression<T> getSelection();
}
public interface CriteriaBuilder {
interface In<T> extends Predicate {
In<T> value(@NonNull T value);
}
interface Coalesce<T> extends Expression<T> {
Coalesce<T> value(@Nullable T value);
}
public static interface SimpleCase<C,R> extends Expression<R> {
SimpleCase<C, R> when(C condition, @Nullable R result);
SimpleCase<C, R> when(Expression<? extends C> condition, @Nullable R result);
Expand All @@ -117,26 +125,28 @@ public interface CriteriaBuilder {
}
public interface Join<Z, X> extends From<Z, X> {
Join<Z, X> on(@Nullable Expression<Boolean> restriction);
Join<Z, X> on(@Nullable Predicate... restrictions);
Join<Z, X> on(Predicate @Nullable... restrictions);
@Nullable Predicate getOn();
@Nullable From<?, Z> getParent();
@Nullable Attribute<? super Z, ?> getAttribute();
}
public interface SetJoin<Z,E> extends PluralJoin<Z, Set<E>, E> {
SetJoin<Z, E> on(@Nullable Expression<Boolean> restriction);
SetJoin<Z, E> on(@Nullable Predicate... restrictions);
SetJoin<Z, E> on(Predicate @Nullable... restrictions);
}
public interface ListJoin<Z,E> extends PluralJoin<Z, List<E>, E> {
ListJoin<Z, E> on(@Nullable Expression<Boolean> restriction);
ListJoin<Z, E> on(@Nullable Predicate... restrictions);
ListJoin<Z, E> on(Predicate @Nullable... restrictions);
}
public interface MapJoin<Z,K,V> extends PluralJoin<Z, Map<K,V>, V> {
MapJoin<Z,K,V> on(@Nullable Expression<Boolean> restriction);
MapJoin<Z,K,V> on(@Nullable Predicate... restrictions);
MapJoin<Z,K,V> on(Predicate @Nullable... restrictions);
}
public interface Path<X> extends Expression<X> {
// CteRoot etc.
@Nullable Bindable<X> getModel();
@Nullable Path<?> getParentPath();
MapJoin<Z,K,V> on(@Nullable Predicate... restrictions);
MapJoin<Z,K,V> on(Predicate @Nullable... restrictions);
}

package jakarta.persistence.metamodel;
Expand Down
10 changes: 10 additions & 0 deletions checkerstubs/jboss.logging.astub
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@ public interface BasicLogger {
public interface Logger {
void tracev(String format, @Nullable Object param1);
void tracef(String format, @Nullable Object param1);
void tracev(String format, @Nullable Object param1, @Nullable Object param2);
void tracef(String format, @Nullable Object param1, @Nullable Object param2);
void warnv(String format, @Nullable Object param1);
void warnf(String format, @Nullable Object param1);
void warnv(String format, @Nullable Object param1, @Nullable Object param2);
void warnf(String format, @Nullable Object param1, @Nullable Object param2);
void debugv(String format, @Nullable Object param1);
void debugf(String format, @Nullable Object param1);
void debugv(String format, @Nullable Object param1, @Nullable Object param2);
void debugf(String format, @Nullable Object param1, @Nullable Object param2);
}
10 changes: 6 additions & 4 deletions hibernate-core/src/main/java/org/hibernate/QueryException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package org.hibernate;

import org.checkerframework.checker.nullness.qual.Nullable;

/**
* A problem occurred translating a Hibernate query to SQL due to illegal query
* syntax, an operation which is not well-typed, an unresolvable reference to
Expand All @@ -23,7 +25,7 @@
* @see org.hibernate.query.SyntaxException
*/
public class QueryException extends HibernateException {
private final String queryString;
private final @Nullable String queryString;

/**
* Constructs a {@code QueryException} using the specified exception message.
Expand Down Expand Up @@ -58,7 +60,7 @@ public QueryException(String message, Exception cause) {
* @param message A message explaining the exception condition
* @param queryString The query being evaluated when the exception occurred
*/
public QueryException(String message, String queryString) {
public QueryException(String message, @Nullable String queryString) {
this( message, queryString, null );
}

Expand All @@ -69,7 +71,7 @@ public QueryException(String message, String queryString) {
* @param queryString The query being evaluated when the exception occurred
* @param cause The underlying cause
*/
public QueryException(String message, String queryString, Exception cause) {
public QueryException(String message, @Nullable String queryString, Exception cause) {
super( message, cause );
this.queryString = queryString;
}
Expand All @@ -93,7 +95,7 @@ public QueryException(Exception cause) {
*
* @return The query string
*/
public String getQueryString() {
public @Nullable String getQueryString() {
return queryString;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
*/
public class DateTruncEmulation extends AbstractSqmFunctionDescriptor implements FunctionRenderer {
protected final String toDateFunction;
private final SqmFormat sqmFormat;

protected DateTruncEmulation(String toDateFunction, TypeConfiguration typeConfiguration) {
super(
Expand All @@ -49,7 +48,6 @@ protected DateTruncEmulation(String toDateFunction, TypeConfiguration typeConfig
StandardFunctionArgumentTypeResolvers.invariant( typeConfiguration, TEMPORAL, TEMPORAL_UNIT )
);
this.toDateFunction = toDateFunction;
this.sqmFormat = new SqmFormat( "yyyy-MM-dd HH:mm:ss", typeConfiguration.getBasicTypeForJavaType( String.class ), null );
}

@Override
Expand Down Expand Up @@ -106,7 +104,7 @@ protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(
final var datetime = arguments.get( 0 );
final var formatExpression =
queryEngine.getSqmFunctionRegistry()
.findFunctionDescriptor( "format" )
.getFunctionDescriptor( "format" )
.generateSqmExpression(
asList(
datetime,
Expand All @@ -119,7 +117,7 @@ protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(
if ( literal != null ) {
formattedDatetime =
queryEngine.getSqmFunctionRegistry()
.findFunctionDescriptor( "concat" )
.getFunctionDescriptor( "concat" )
.generateSqmExpression(
asList(
formatExpression,
Expand All @@ -137,7 +135,7 @@ protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(
this,
this,
// the first argument is needed for SybaseDateTruncEmulation
asList( datetime, formattedDatetime, sqmFormat ),
asList( datetime, formattedDatetime, new SqmFormat( "yyyy-MM-dd HH:mm:ss", nodeBuilder.getStringType(), nodeBuilder ) ),
impliedResultType,
null,
getReturnTypeResolver(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.model.domain.DomainType;
import org.hibernate.metamodel.model.domain.ReturnableType;
import org.hibernate.query.sqm.SqmBindableType;
import org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.query.sqm.tree.SqmTypedNode;
Expand Down Expand Up @@ -61,22 +62,28 @@ else if ( inferredType instanceof BasicValuedMapping basicValuedMapping ) {
}
if ( elementIndex == -1 ) {
for ( SqmTypedNode<?> argument : arguments ) {
final DomainType<?> sqmType = argument.getExpressible().getSqmType();
final SqmBindableType<?> expressible = argument.getExpressible();
if ( expressible != null ) {
final DomainType<?> sqmType = expressible.getSqmType();
if ( sqmType instanceof ReturnableType<?> ) {
return list
? DdlTypeHelper.resolveListType( sqmType, typeConfiguration )
: DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
}
}
}
}
else {
final SqmBindableType<?> expressible = arguments.get( elementIndex ).getExpressible();
if ( expressible != null ) {
final DomainType<?> sqmType = expressible.getSqmType();
if ( sqmType instanceof ReturnableType<?> ) {
return list
? DdlTypeHelper.resolveListType( sqmType, typeConfiguration )
: DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
}
}
}
else {
final DomainType<?> sqmType = arguments.get( elementIndex ).getExpressible().getSqmType();
if ( sqmType instanceof ReturnableType<?> ) {
return list
? DdlTypeHelper.resolveListType( sqmType, typeConfiguration )
: DdlTypeHelper.resolveArrayType( sqmType, typeConfiguration );
}
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package org.hibernate.engine.query.spi;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.hibernate.Incubating;
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
import org.hibernate.metamodel.model.domain.internal.EntityTypeImpl;
Expand All @@ -19,39 +20,38 @@
public abstract class AbstractParameterDescriptor<T> implements QueryParameter<T> {
private final int[] sourceLocations;

private BindableType<T> expectedType;
private @Nullable BindableType<T> expectedType;

public AbstractParameterDescriptor(int[] sourceLocations, BindableType<T> expectedType) {
public AbstractParameterDescriptor(int[] sourceLocations, @Nullable BindableType<T> expectedType) {
this.sourceLocations = sourceLocations;
this.expectedType = expectedType;
}

@Override
public String getName() {
public @Nullable String getName() {
return null;
}

@Override
public Integer getPosition() {
public @Nullable Integer getPosition() {
return null;
}

@Override
public Class<T> getParameterType() {
public @Nullable Class<T> getParameterType() {
return expectedType == null ? null : expectedType.getJavaType();
}

@Override
public BindableType<T> getHibernateType() {
public @Nullable BindableType<T> getHibernateType() {
return getExpectedType();
}


public BindableType<T> getExpectedType() {
public @Nullable BindableType<T> getExpectedType() {
return expectedType;
}

public void resetExpectedType(BindableType<T> expectedType) {
public void resetExpectedType(@Nullable BindableType<T> expectedType) {
this.expectedType = expectedType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ void missingArguments(
@LogMessage(level = WARN)
@Message(value = "The query [%s] updates an immutable entity: %s",
id = 487)
void immutableEntityUpdateQuery(String sourceQuery, String querySpaces);
void immutableEntityUpdateQuery(@Nullable String sourceQuery, String querySpaces);

@LogMessage(level = DEBUG)
@Message(value = "The query [%s] updates an immutable entity: %s",
id = 488)
void immutableEntityUpdateQueryAllowed(String sourceQuery, String querySpaces);
void immutableEntityUpdateQueryAllowed(@Nullable String sourceQuery, String querySpaces);

@LogMessage(level = INFO)
@Message(value = "No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)", id = 489)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.Consumer;
import jakarta.persistence.metamodel.IdentifiableType;
import jakarta.persistence.metamodel.SingularAttribute;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* Extension to the JPA {@link IdentifiableType} contract.
Expand All @@ -18,7 +19,7 @@
public interface IdentifiableDomainType<J>
extends ManagedDomainType<J>, IdentifiableType<J> {

PathSource<?> getIdentifierDescriptor();
@Nullable PathSource<?> getIdentifierDescriptor();

@Override
<Y> SingularPersistentAttribute<? super J, Y> getId(Class<Y> type);
Expand All @@ -39,15 +40,15 @@ public interface IdentifiableDomainType<J>
SimpleDomainType<?> getIdType();

@Override
IdentifiableDomainType<? super J> getSupertype();
@Nullable IdentifiableDomainType<? super J> getSupertype();

boolean hasIdClass();

SingularPersistentAttribute<? super J,?> findIdAttribute();
@Nullable SingularPersistentAttribute<? super J,?> findIdAttribute();

void visitIdClassAttributes(Consumer<SingularPersistentAttribute<? super J,?>> action);

SingularPersistentAttribute<? super J, ?> findVersionAttribute();
@Nullable SingularPersistentAttribute<? super J, ?> findVersionAttribute();

List<? extends PersistentAttribute<? super J, ?>> findNaturalIdAttributes();
@Nullable List<? extends PersistentAttribute<? super J, ?>> findNaturalIdAttributes();
}
Loading
Loading