tarantool / cartridge-springdata

Spring Data Tarantool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index search :max()

littl3rud3 opened this issue · comments

Custom created function
function find_by_party_id_and_max_insert_time(partyId) return box.space.legal_entity.index.party_id_time_idx:max(partyId) end
Repository
@Query(function = "find_by_party_id_and_max_insert_time") Optional<ExampleObject> findByPartyIdAndMaxInsertTime(UUID partyId);

Throws error org.springframework.data.mapping.MappingException: Cannot map object of type class java.util.ArrayList to object of type class

This is due to the fact that the result of method execute returns array of fields that not wrapped in TarantoolFieldImpl. If I'll use select{} instead of max() there will be no error and everything work correctly

image

@littl3rud3 Which version of "cartridge-springdata" do you use?

@littl3rud3 Which version of "cartridge-springdata" do you use?

0.5.2

You could use a simple workaround just wrap a return value with the table in Lua function
function find_by_party_id_and_max_insert_time(partyId) return { box.space.legal_entity.index.party_id_time_idx:max(partyId) } end

Please reopen the ticket if this workaround doesn't work for you/