Record Class ConstructorMapping<T>

java.lang.Object
java.lang.Record
jakarta.persistence.sql.ConstructorMapping<T>
Type Parameters:
T - The type of the Java class
Record Components:
targetClass - The Java class which declares the constructor
arguments - Mappings assigned to the parameters of the constructor
All Implemented Interfaces:
MappingElement<T>, ResultSetMapping<T>, TupleElement<T>

public record ConstructorMapping<T>(Class<T> targetClass, MappingElement<?>[] arguments) extends Record implements MappingElement<T>, ResultSetMapping<T>
Maps columns of a JDBC ResultSet to parameters of the constructor of a Java class.
Since:
4.0
See Also:
  • Constructor Details

    • ConstructorMapping

      public ConstructorMapping(Class<T> targetClass, MappingElement<?>[] arguments)
      Creates an instance of a ConstructorMapping record class.
      Parameters:
      targetClass - the value for the targetClass record component
      arguments - the value for the arguments record component
  • Method Details

    • getJavaType

      public Class<T> getJavaType()
      The Java class which declares the constructor.
      Specified by:
      getJavaType in interface TupleElement<T>
      Returns:
      the Java type of the tuple element
    • getAlias

      public String getAlias()
      Always returns null.
      Specified by:
      getAlias in interface TupleElement<T>
      Returns:
      alias
    • of

      public static <T> ConstructorMapping<T> of(Class<T> targetClass, MappingElement<?>... arguments)
      Construct a new instance.
      Type Parameters:
      T - The type of the Java class
      Parameters:
      targetClass - The Java class which declares the constructor
      arguments - Mappings assigned to the parameters of the constructor
    • type

      public Class<T> type()
      The Java class which declares the constructor.
      Specified by:
      type in interface ResultSetMapping<T>
    • 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.
    • targetClass

      public Class<T> targetClass()
      Returns the value of the targetClass record component.
      Returns:
      the value of the targetClass record component
    • arguments

      public MappingElement<?>[] arguments()
      Returns the value of the arguments record component.
      Returns:
      the value of the arguments record component