You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Добрый день. Средствами cartridge-springdata можно как-то сложить данные в бинарном виде? Пробовал менять поле на varbinary, говорит, что не может строку преобразовать в varbinary, хотя в сущности поле определено с типом byte[]. Пробовал в тарантуле поле оставлять строковым, а в сущности byte[], тоже не работает. В тестах репозитория не нашел примеров с вставкой бинарных данных в тарантул средствами java
To reproduce the problem, I took an existing test by adding a byte [] field to the entity
diff --git a/src/test/java/org/springframework/data/tarantool/entities/BookTranslation.java b/src/test/java/org/springframework/data/tarantool/entities/BookTranslation.java
index 7ea062d..6e573a7 100644
--- a/src/test/java/org/springframework/data/tarantool/entities/BookTranslation.java+++ b/src/test/java/org/springframework/data/tarantool/entities/BookTranslation.java@@ -33,4 +33,6 @@ public class BookTranslation {
private String translator;
private String comments;
++ private byte[] bytesString;
}
diff --git a/src/test/java/org/springframework/data/tarantool/repository/support/CompositePkIntegrationTest.java b/src/test/java/org/springframework/data/tarantool/repository/support/CompositePkIntegrationTest.java
index 1b42bd1..b7c69ea 100644
--- a/src/test/java/org/springframework/data/tarantool/repository/support/CompositePkIntegrationTest.java+++ b/src/test/java/org/springframework/data/tarantool/repository/support/CompositePkIntegrationTest.java@@ -62,6 +62,7 @@ class CompositePkIntegrationTest extends BaseIntegrationTest {
.edition(22)
.translator("Ivan Ivanov")
.comments("Some translation")
+ .bytesString("Hello".getBytes())
.build();
BookTranslation newTranslation = bookTranslationRepository.save(translation);
assertThat(newTranslation).isEqualTo(translation);
diff --git a/src/test/resources/cartridge/app/roles/api_storage.lua b/src/test/resources/cartridge/app/roles/api_storage.lua
index cdc7fa6..3f1ad7f 100644
--- a/src/test/resources/cartridge/app/roles/api_storage.lua+++ b/src/test/resources/cartridge/app/roles/api_storage.lua@@ -86,6 +86,7 @@ local function init_space()
{ name = 'edition', type = 'integer' },
{ name = 'translator', type = 'string' },
{ name = 'comments', type = 'string', is_nullable = true },
+ { name = 'bytesString', type = 'string', is_nullable = true }
},
if_not_exists = true,
}
Reproducer showed that data is written to tarantool normally, since messagePack binary is processed as a string in a tarantool. But we cannot get them back to java, since messagePack String comes and we are trying to convert it tobyte []
The problem is that byte [] is collection, and the code asks us to return list
Storing byte arrays in the fields of type string requires a custom string-to-byte-array conversion on the client level using SpringData's custom converters mechanism (see
). It is a valid w/a for this case, although creating Strings and then converting them into byte arrays may result in a huge memory overhead on the client.
To reproduce the problem, I took an existing test by adding a byte [] field to the entity
Reproducer showed that data is written to tarantool normally, since messagePack
binary
is processed as a string in a tarantool. But we cannot get them back to java, since messagePackString
comes and we are trying to convert it tobyte []
The problem is that byte [] is collection, and the code asks us to return list
cartridge-springdata/src/main/java/org/springframework/data/tarantool/core/convert/MappingTarantoolReadConverter.java
Lines 200 to 201 in 5e06e8f
The workaround was to use a custom mapper:
Also globally the problem may be related to this: tarantool/tarantool#1629
The text was updated successfully, but these errors were encountered: