tarantool / cartridge-springdata

Spring Data Tarantool
Other
18 stars 7 forks source link

Index search :max() #131

Closed littl3rud3 closed 1 year ago

littl3rud3 commented 1 year ago

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

dkasimovskiy commented 1 year ago

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

littl3rud3 commented 1 year ago

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

0.5.2

dkasimovskiy commented 1 year ago

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/