Record Class EntityMapping<T>
java.lang.Object
java.lang.Record
jakarta.persistence.sql.EntityMapping<T>
- Type Parameters:
T- The entity type- Record Components:
entityClass- The entity classlockMode- The lock mode acquired by the SQL querydiscriminatorColumn- The name of the column holding the discriminator; anullvalue indicates that there is no discriminator column.fields- Mappings for fields or properties of the entity and of its entity subclassesalias- An optional alias
- All Implemented Interfaces:
MappingElement<T>, ResultSetMapping<T>, TupleElement<T>
public record EntityMapping<T>(@Nonnull Class<T> entityClass, @Nonnull LockModeType lockMode, @Nullable String discriminatorColumn, @Nonnull MemberMapping<? extends T>[] fields, @Nullable String alias)
extends Record
implements MappingElement<T>, ResultSetMapping<T>
- Since:
- 4.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEntityMapping(Class<T> entityClass, LockModeType lockMode, String discriminatorColumn, MemberMapping<? extends T>[] fields, String alias) Creates an instance of aEntityMappingrecord class. -
Method Summary
Modifier and TypeMethodDescriptionalias()Returns the value of thealiasrecord component.Returns the value of thediscriminatorColumnrecord component.Returns the value of theentityClassrecord component.final booleanIndicates whether some other object is "equal to" this one.MemberMapping<? extends T>[]fields()Returns the value of thefieldsrecord component.getAlias()Return the alias specified viawithAlias(String), which may be used to retrieve an entity instance usingTuple.get(String, Class)The entity class.final inthashCode()Returns a hash code value for this object.lockMode()Returns the value of thelockModerecord component.static <T> EntityMapping<T> of(Class<T> entityClass, MemberMapping<T>... fields) Construct a new instance.static <T> EntityMapping<T> of(Class<T> entityClass, String discriminatorColumn, MemberMapping<? extends T>... fields) Construct a new instance.final StringtoString()Returns a string representation of this record class.type()The entity class.Specify an alias for this entity in the result set.withLockMode(LockModeType lockMode) Specify the lock mode obtained on this entity.
-
Constructor Details
-
EntityMapping
public EntityMapping(@Nonnull Class<T> entityClass, @Nonnull LockModeType lockMode, @Nullable String discriminatorColumn, @Nonnull MemberMapping<? extends T>[] fields, @Nullable String alias) Creates an instance of aEntityMappingrecord class.- Parameters:
entityClass- the value for theentityClassrecord componentlockMode- the value for thelockModerecord componentdiscriminatorColumn- the value for thediscriminatorColumnrecord componentfields- the value for thefieldsrecord componentalias- the value for thealiasrecord component
-
-
Method Details
-
fields
-
getJavaType
The entity class.- 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 an entity instance usingTuple.get(String, Class)- Specified by:
getAliasin interfaceTupleElement<T>- Returns:
- the explicitly specified alias or
null
-
withAlias
Specify an alias for this entity in the result set.- Specified by:
withAliasin interfaceMappingElement<T>- Parameters:
alias- The alias
-
withLockMode
Specify the lock mode obtained on this entity.- Parameters:
lockMode- The lock mode
-
of
@Nonnull @SafeVarargs public static <T> EntityMapping<T> of(@Nonnull Class<T> entityClass, @Nonnull MemberMapping<T>... fields) Construct a new instance.- Type Parameters:
T- The entity type- Parameters:
entityClass- The entity classfields- Mappings for fields or properties of the entity
-
of
@Nonnull @SafeVarargs public static <T> EntityMapping<T> of(@Nonnull Class<T> entityClass, @Nonnull String discriminatorColumn, @Nonnull MemberMapping<? extends T>... fields) Construct a new instance.- Type Parameters:
T- The entity type- Parameters:
entityClass- The entity classdiscriminatorColumn- The name of the column holding the discriminator; anullvalue indicates that there is no discriminator column.fields- Mappings for fields or properties of the entity and of its entity subclasses
-
type
The entity class.- 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). -
entityClass
Returns the value of theentityClassrecord component.- Returns:
- the value of the
entityClassrecord component
-
lockMode
-
discriminatorColumn
Returns the value of thediscriminatorColumnrecord component.- Returns:
- the value of the
discriminatorColumnrecord component
-
alias
-