-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#24: FIX: Using query() DSL with a custom value type caused ClassCast…
…Exception
- Loading branch information
1 parent
060b9a9
commit 64c5315
Showing
11 changed files
with
130 additions
and
24 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
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
19 changes: 19 additions & 0 deletions
19
repository-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/Version.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tech.ydb.yoj.repository.test.sample.model; | ||
|
||
import lombok.NonNull; | ||
import tech.ydb.yoj.databind.converter.ValueConverter; | ||
import tech.ydb.yoj.databind.schema.Schema.JavaField; | ||
|
||
public record Version(long value) { | ||
public static final class Converter implements ValueConverter<Version, Long> { | ||
@Override | ||
public @NonNull Long toColumn(@NonNull JavaField field, @NonNull Version v) { | ||
return v.value(); | ||
} | ||
|
||
@Override | ||
public @NonNull Version toJava(@NonNull JavaField field, @NonNull Long value) { | ||
return new Version(value); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
repository-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/VersionedEntity.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package tech.ydb.yoj.repository.test.sample.model; | ||
|
||
import tech.ydb.yoj.databind.CustomValueType; | ||
import tech.ydb.yoj.databind.FieldValueType; | ||
import tech.ydb.yoj.databind.schema.Column; | ||
import tech.ydb.yoj.repository.db.Entity; | ||
import tech.ydb.yoj.repository.db.RecordEntity; | ||
|
||
public record VersionedEntity( | ||
Id id, | ||
@Column( | ||
customValueType = @CustomValueType( | ||
columnValueType = FieldValueType.INTEGER, | ||
columnClass = Long.class, | ||
converter = Version.Converter.class | ||
) | ||
) | ||
Version version2 | ||
) implements RecordEntity<VersionedEntity> { | ||
public record Id( | ||
String value, | ||
@Column( | ||
customValueType = @CustomValueType( | ||
columnValueType = FieldValueType.INTEGER, | ||
columnClass = Long.class, | ||
converter = Version.Converter.class | ||
) | ||
) | ||
Version version | ||
) implements Entity.Id<VersionedEntity> { | ||
} | ||
} |
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