Record Class ColumnMapping<T>
java.lang.Object
java.lang.Record
jakarta.persistence.sql.ColumnMapping<T>
- Type Parameters:
T- The type of the resulting scalar value- Record Components:
columnName- The name of the mapped column of the result settype- The Java type of the resulting scalar valuealias- An optional alias
- All Implemented Interfaces:
MappingElement<T>, ResultSetMapping<T>, TupleElement<T>
public record ColumnMapping<T>(@Nonnull String columnName, @Nonnull Class<T> type, @Nullable String alias)
extends Record
implements MappingElement<T>, ResultSetMapping<T>
Maps a column of a JDBC
ResultSet to a scalar
value in the result returned by the query.- Since:
- 4.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionColumnMapping(String columnName, Class<T> type, String alias) Creates an instance of aColumnMappingrecord class. -
Method Summary
Modifier and TypeMethodDescriptionalias()Returns the value of thealiasrecord component.Returns the value of thecolumnNamerecord component.final booleanIndicates whether some other object is "equal to" this one.getAlias()The colum name.The Java type of the scalar value.final inthashCode()Returns a hash code value for this object.static ColumnMapping<Object> Construct a new instance.static <T> ColumnMapping<T> Construct a new instance.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.Specify an alias for this column in the result set.
-
Constructor Details
-
ColumnMapping
Creates an instance of aColumnMappingrecord class.- Parameters:
columnName- the value for thecolumnNamerecord componenttype- the value for thetyperecord componentalias- the value for thealiasrecord component
-
-
Method Details
-
getJavaType
The Java type of the scalar value.- Specified by:
getJavaTypein interfaceTupleElement<T>- Returns:
- the Java type of the tuple element
-
getAlias
The colum name.- Specified by:
getAliasin interfaceTupleElement<T>- Returns:
- alias
-
withAlias
Specify an alias for this column in the result set.- Specified by:
withAliasin interfaceMappingElement<T>- Parameters:
alias- The alias
-
of
Construct a new instance.- Parameters:
columnName- The name of the mapped column of the result set
-
of
Construct a new instance.- Type Parameters:
T- The type of the resulting scalar value- Parameters:
columnName- The name of the mapped column of the result settype- The Java type of the resulting scalar value
-
toString
-
hashCode
-
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). -
columnName
Returns the value of thecolumnNamerecord component.- Returns:
- the value of the
columnNamerecord component
-
type
-
alias
-