Package org.hibernate.query
Record Class TypedParameterValue<J>
java.lang.Object
java.lang.Record
org.hibernate.query.TypedParameterValue<J>
Represents a typed argument to a query parameter.
Usually, the Hibernate 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 of TypedParameterValue may be passed to
setParameter().
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 Summary
ConstructorsConstructorDescriptionTypedParameterValue(BindableType<J> type, J value) Creates an instance of aTypedParameterValuerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.getType()Deprecated.Deprecated.usetypegetValue()Deprecated.usevaluefinal inthashCode()Returns a hash code value for this object.static <J> TypedParameterValue<J> Obtain an instance with the given type and given value.static <J> TypedParameterValue<J> Obtain an instance with the given type and a null value.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
TypedParameterValue
Creates an instance of aTypedParameterValuerecord class.- Parameters:
type- the value for thetyperecord componentvalue- the value for thevaluerecord component
-
-
Method Details
-
of
Obtain an instance with the given type and given value.- Since:
- 7.0
-
ofNull
Obtain an instance with the given type and a null value.- Since:
- 7.0
-
getValue
Deprecated.usevalueThe value to bind- Returns:
- The value to be bound
-
getType
Deprecated.usetypeThe specific Hibernate type to use to bind the value.- Returns:
- The Hibernate type to use.
-
getTypeReference
Deprecated.usetypeThe specific Hibernate type reference to use to bind the value.- Returns:
- The Hibernate type reference to use.
-
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. -
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. -
equals
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). -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
type