-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query multiple tables using one entity (review comments)
- Loading branch information
Sergei Galiamichev
committed
Nov 23, 2024
1 parent
c4a68fe
commit 4e127c8
Showing
6 changed files
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
repository/src/main/java/tech/ydb/yoj/repository/db/EntityDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package tech.ydb.yoj.repository.db; | ||
|
||
import tech.ydb.yoj.databind.schema.Schema; | ||
import lombok.NonNull; | ||
import tech.ydb.yoj.ExperimentalApi; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@ExperimentalApi(issue="https://github.com/ydb-platform/yoj-project/issues/32") | ||
public record EntityDescriptor<E extends Entity<E>>(Class<E> clazz, @Nullable String tableName) { | ||
public String getTableName(Schema<?> schema) { | ||
public String getTableName(@NonNull EntitySchema<?> schema) { | ||
return tableName != null ? tableName : schema.getName(); | ||
} | ||
|
||
public static <E extends Entity<E>> EntityDescriptor<E> of(Class<E> clazz) { | ||
public static <E extends Entity<E>> EntityDescriptor<E> of(@NonNull Class<E> clazz) { | ||
return new EntityDescriptor<>(clazz, null); | ||
} | ||
} |