Record Class FieldMapping<C,T>

java.lang.Object
java.lang.Record
jakarta.persistence.sql.FieldMapping<C,T>
Type Parameters:
C - The type of the entity or embeddable type
T - The type of the field
Record Components:
container - The Java class which declares the field
type - The Java class of the field
name - The name of the field
columnName - The name of the mapped column of the result set
All Implemented Interfaces:
MemberMapping<C>

public record FieldMapping<C,T>(@Nonnull Class<? super C> container, @Nonnull Class<T> type, @Nonnull String name, @Nonnull String columnName) extends Record implements MemberMapping<C>
Maps a column of a JDBC ResultSet to a given field or column of an entity or embeddable type.
Since:
4.0
See Also:
  • Constructor Details

    • FieldMapping

      public FieldMapping(@Nonnull Class<? super C> container, @Nonnull Class<T> type, @Nonnull String name, @Nonnull String columnName)
      Creates an instance of a FieldMapping record class.
      Parameters:
      container - the value for the container record component
      type - the value for the type record component
      name - the value for the name record component
      columnName - the value for the columnName record component
  • Method Details

    • of

      @Nonnull public static <C,T> FieldMapping<C,T> of(@Nonnull Class<? super C> container, @Nonnull Class<T> type, @Nonnull String name, @Nonnull String columnName)
      Construct a new instance.
      Type Parameters:
      C - The type of the entity or embeddable type
      T - The type of the field
      Parameters:
      container - The Java class which declares the field
      type - The Java class of the field
      name - The name of the field
      columnName - The name of the mapped column of the result set
    • of

      @Nonnull public static <C,T> FieldMapping<C,T> of(@Nonnull SingularAttribute<? super C, T> attribute, @Nonnull String columnName)
      Construct a new instance.
      Type Parameters:
      C - The type of the entity or embeddable type
      T - The type of the field
      Parameters:
      attribute - The metamodel object representing the field
      columnName - The name of the mapped column of the result set
    • 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 with Objects::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 the o argument; false otherwise.
    • container

      @Nonnull public Class<? super C> container()
      Returns the value of the container record component.
      Returns:
      the value of the container record component
    • type

      @Nonnull public Class<T> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • name

      @Nonnull public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • columnName

      @Nonnull public String columnName()
      Returns the value of the columnName record component.
      Returns:
      the value of the columnName record component