0

I have a custom model for order and item that will hold minimum data than the actual entity class

Models

class OrderMinimalModel {    
    long id;    
    String comment;    
    List<ItemMinimalModel> items;
}

class ItemMinimalModel{    
    long id;    
    String name;
}

Query I am looking for

@Query( value = "SELECT O.id as orderId, O.comment as orderComment, I.id as itemId, I.name as itemName FROM order O "
        + " left join item I on I.order_id = O.id"
        + " WHERE O.status = 1 ",nativeQuery = true)
List<OrderMinimalModel > findAllOrderMinimal();

But I am getting bellow error

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.example.model.OrderMinimalModel]

Maybe I am doing wrong.

Bikesh M
  • 8,163
  • 6
  • 40
  • 52
  • Not sure if you looked at this link. https://stackoverflow.com/questions/13012584/jpa-how-to-convert-a-native-query-result-set-to-pojo-class-collection – Kumar V May 08 '20 at 13:42
  • Take a look on https://stackoverflow.com/questions/58909163/could-not-extract-result-set-after-using-pagepagable-springboot/58910147?noredirect=1#comment104835503_58910147 – DEBENDRA DHINDA Jun 09 '20 at 11:02

0 Answers0