Skip to Content
1
Former Member
May 01, 2017 at 06:34 PM

Hybris returns list of lists from querying database

351 Views

In my project, whenever we want to pull data across multiple database tables (i.e. using JOIN’s in flexible SQL) we have to call DefautFlexibleSearchService.search(FlexibleSearchQuery query) to get a list of lists and then convert it into a list of POJO objects. When the size of the result set is large it’s causing performance problems. I’m wondering if we have a different approach to query database. For example something similar to Spring JDBC in which we specify O-R mapping in Mappers before we query database and then directly get a list of POJO objects.

Example:

  String query = "QUERY";
  FlexibleSearchQuery fQuery = new FlexibleSearchQuery(query);
 
  List resultClass = new ArrayList();
  resultClass.add(String.class);
  resultClass.add(Long.class);
  fQuery.setResultClasses(resultClass);
 
  SearchResult result = getFlexibleSearchService().search(fQuery)
  List elements = result.getResult();
 
  for (Object result: elements) {
    Long invoiceNumber = (Long)((List) result).get(1);
    String orderNumber = (String)((List) result).get(0);
  }