Java Magazine, Nov/Dec 2017
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2017 51 java ee 8 public void findByCustomer PoolCustomer customer Stream Job jobList em createQuery select object o from Job o where o customer customer getResultStream jobList map j j getCustomerId getCustomerId getCustomerId ordered job j getId Starting j getWorkDate forEach jm System out println jm This method can be modified slightly to return a list of results by using the Collectors toList utility method as follows public List Job findByCustomer PoolCustomer customer Stream Job jobList em createQuery select object o from Job o where o customerId customer setParameter customer customer getResultStream return jobList collect Collectors toList In the next scenario shown below I find a List of jobs that pertain to pools of a particular shape In this instance I return all jobs that match the shape passed in as a string Similar to the first example I first return a stream of Job records Next I filter the records based on the customers pool shape As can be seen the resulting code is concise and very easy to read public List Job findByCustPoolShape
You must have JavaScript enabled to view digital editions.