Skip to Content
0
Former Member
Oct 19, 2016 at 11:09 AM

flexible search query return null in java file but working fine in hac

666 Views

Hi I am trying to fetch some data through a method. My query is working fine in hac but it result null when used in java code. Below is my java code ;-

 public class abc
     {
            @Resource
         private UserService userService;
         @Resource
         private SearchRestrictionService searchRestrictionService;
         @Resource
         private CatalogVersionService catalogVersionService;
     
             public List<ProductModel> findRequiredProducts()
             {
                 this.userService.setCurrentUser(userService.getAdminUser());
                 this.searchRestrictionService.disableSearchRestrictions();
                     this.catalogVersionService.setSessionCatalogVersion("abcCatalog", "Online");
              final String query = "select {p:name},{p.creationtime} from {Product! as p}";
              final FlexibleSearchQuery productQuery = new FlexibleSearchQuery(query);
              final SearchResult<ProductModel> searchResult = getFlexibleSearchService().search(productquery);
              this.searchRestrictionService.enableSearchRestrictions();
             final List<ProductModel> requiredProducts = searchResult.getResult();
     
             }
       
     }
 

Here on executing this code I am getting lazylist[null]" in requiredProduct list. Please suggest the solution.