Class ProjectionMappings
java.lang.Object
tech.ydb.yoj.repository.db.projection.ProjectionMappings
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classProjectionMappings.ListViaProjection<P extends Entity<P>> -
Method Summary
Modifier and TypeMethodDescriptionlenientFieldMapping(@NonNull Class<P> projectionType, @NonNull Class<T> entityType) Creates a lenient one-to-one mapping from entity fields to projection fields, which contains allstrict mappings, plus mappings of the form<entity field> <-> <projection field with the same path>(if both fields exist).static <P extends Entity<P>>
@NonNull ProjectionMappings.ListViaProjection<P>listViaProjection(@NonNull Class<P> projectionType) strictFieldMapping(@NonNull Class<P> projectionType, @NonNull Class<T> entityType) Creates a one-to-one mapping from entity fields to entity projection ID fields, assuming that the projection ID contains fields with the same name as in the main entity and at most one field for the main entity ID (with any name).
-
Method Details
-
lenientFieldMapping
@NonNull public static <P extends Entity<P>,T extends Entity<T>> @NonNull Map<String,String> lenientFieldMapping(@NonNull @NonNull Class<P> projectionType, @NonNull @NonNull Class<T> entityType) Creates a lenient one-to-one mapping from entity fields to projection fields, which contains allstrict mappings, plus mappings of the form<entity field> <-> <projection field with the same path>(if both fields exist).- Type Parameters:
P- projection typeT- entity type- Parameters:
projectionType- projection classentityType- entity class- Returns:
- Map: Entity field path -> Projection field path
- See Also:
-
strictFieldMapping
@NonNull public static <P extends Entity<P>,T extends Entity<T>> @NonNull Map<String,String> strictFieldMapping(@NonNull @NonNull Class<P> projectionType, @NonNull @NonNull Class<T> entityType) Creates a one-to-one mapping from entity fields to entity projection ID fields, assuming that the projection ID contains fields with the same name as in the main entity and at most one field for the main entity ID (with any name).E.g., the following entity-projection pair qualifies:
@Value class MyEntity implements Entity<MyEntity> { Id id; String field; @Value static class Id implements Entity.Id<MyEntity> { String value; } } @Value class MyIndex implements Entity<MyIndex> { Id id; @Value static class Id implements Entity.Id<MyIndex> { // MUST have the same Java field name as in the entity class // (DB name specified in @Column annotation does not matter.) String field; // OPTIONAL. If present, this field MAY have any name MyEntity.Id entityId; } }- Type Parameters:
P- projection typeT- entity type- Parameters:
projectionType- projection classentityType- entity class- Returns:
- Bidirectional mapping: Entity field path -> Projection field path
-
listViaProjection
@NonNull public static <P extends Entity<P>> @NonNull ProjectionMappings.ListViaProjection<P> listViaProjection(@NonNull @NonNull Class<P> projectionType)
-