Package org.hibernate.query

Record Class TypedParameterValue<J>

java.lang.Object
java.lang.Record
org.hibernate.query.TypedParameterValue<J>

public recordTypedParameterValue<J>(BindableType<J> type,J value)extendsRecord
Represents a typed argument to a query parameter.

Usually, theHibernate type of an argument to a query parameter may be inferred, and so it's rarely necessary to explicitly pass a type when binding the argument. Occasionally, and especially when the argument is null, the type cannot be inferred and must be explicitly specified. In such cases, an instance ofTypedParameterValue may be passed tosetParameter().

For example:

 query.setParameter("stringNamedParam",         TypedParameterValue.ofNull(StandardBasicTypes.STRING))
 query.setParameter("address",         TypedParameterValue.of(Address_.class_, address))

Here, a "null string" argument was bound to the named parameter:stringNamedParam.

Since:
6
See Also:
  • Constructor Details

    • TypedParameterValue

      public TypedParameterValue(BindableType<J> type,J value)
      Creates an instance of aTypedParameterValue record class.
      Parameters:
      type - the value for thetype record component
      value - the value for thevalue record component
  • Method Details

    • of

      public static <J> TypedParameterValue<J> of(Type<J> type, J value)
      Obtain an instance with the given type and given value.
      Since:
      7.0
    • ofNull

      public static <J> TypedParameterValue<J> ofNull(Type<J> type)
      Obtain an instance with the given type and a null value.
      Since:
      7.0
    • getValue

      @Deprecated(since="7")public J getValue()
      Deprecated.
      usevalue
      The value to bind
      Returns:
      The value to be bound
    • getType

      @Deprecated(since="7")public BindableType<J> getType()
      Deprecated.
      usetype
      The specific Hibernate type to use to bind the value.
      Returns:
      The Hibernate type to use.
    • getTypeReference

      @Deprecated(since="7")public BasicTypeReference<J> getTypeReference()
      Deprecated.
      usetype
      The specific Hibernate type reference to use to bind the value.
      Returns:
      The Hibernate type reference to use.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as theo argument;false otherwise.
    • type

      public BindableType<J> type()
      Returns the value of thetype record component.
      Returns:
      the value of thetype record component
    • value

      public J value()
      Returns the value of thevalue record component.
      Returns:
      the value of thevalue record component