tarantool / cartridge-springdata

Spring Data Tarantool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throws an error if @Tuple is not present in the repository when the @Query annotated method is used and return is Tuple(number indexed table)

ArtDu opened this issue · comments

It is hard to find the error, as there may be strange behavior, for example, returning empty value for a tuple or NPE

It's a working case. But we have to improve error reporting - if the result returned from lua function is not null, but no fields in entity match the metadata or metadata is null.

In similar case we resolved the issue by using same @Tuple not only for entity class but for related repository class too.
Not sure is it right way

It's strange that the SimpleTarantoolRepository functions work when the wrong space name is specified in @Tuple. But when using the @Query function where the return will be the same as findAll(from SimpleTarantoolRepository) - crud.select - there will be the same number of tuples, but the object fields will be NULL.

when the wrong space name is specified in @Tuple

I think we should throw exception in this case

We need to analyze the cases of working with methods in the repository. We need to understand which cases are working and which are not. For example: default methods, like save and find that return a map or a tuple, etc.

If we consider only those cases where we exactly forgot to indicate @Tuple, so far I see one case where exactly throwing Exceptions needs to be done

  1. When we forgot to specify @Tuple, but our return type is tuple (number indexed table) - then cartridge-java converts the response to an ArrayList and passes it on for conversion to cartridge-springdata. We can check if ArrayList arrived to mapToEntity and then raise specific error, because we only accept Map or TarantoolTuple or PrimitiveType.