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 constructorarguments- 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, String alias)
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 Summary
ConstructorsConstructorDescriptionConstructorMapping(Class<T> targetClass, MappingElement<?>[] arguments, String alias) Creates an instance of aConstructorMappingrecord class. -
Method Summary
Modifier and TypeMethodDescriptionalias()Returns the value of thealiasrecord component.MappingElement<?>[]Returns the value of theargumentsrecord component.final booleanIndicates whether some other object is "equal to" this one.getAlias()Return the alias specified viawithAlias(String), which may be used to retrieve a constructed value usingTuple.get(String, Class)The Java class which declares the constructor.final inthashCode()Returns a hash code value for this object.static <T> ConstructorMapping<T> of(Class<T> targetClass, MappingElement<?>... arguments) Construct a new instance.Returns the value of thetargetClassrecord component.final StringtoString()Returns a string representation of this record class.type()The Java class which declares the constructor.Specify an alias for this constructor result in the result set.
-
Constructor Details
-
ConstructorMapping
Creates an instance of aConstructorMappingrecord class.- Parameters:
targetClass- the value for thetargetClassrecord componentarguments- the value for theargumentsrecord componentalias- the value for thealiasrecord component
-
-
Method Details
-
arguments
-
getJavaType
The Java class which declares the constructor.- Specified by:
getJavaTypein interfaceTupleElement<T>- Returns:
- the Java type of the tuple element
-
getAlias
Return the alias specified viawithAlias(String), which may be used to retrieve a constructed value usingTuple.get(String, Class)- Specified by:
getAliasin interfaceTupleElement<T>- Returns:
- the explicitly specified alias or
null
-
withAlias
Specify an alias for this constructor result in the result set.- Specified by:
withAliasin interfaceMappingElement<T>- Parameters:
alias- The alias
-
of
Construct a new instance.- Type Parameters:
T- The type of the Java class- Parameters:
targetClass- The Java class which declares the constructorarguments- Mappings assigned to the parameters of the constructor
-
type
The Java class which declares the constructor.- Specified by:
typein interfaceResultSetMapping<T>
-
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). -
targetClass
Returns the value of thetargetClassrecord component.- Returns:
- the value of the
targetClassrecord component
-
alias
Returns the value of thealiasrecord component.- Returns:
- the value of the
aliasrecord component
-