Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

order entity based on size of collection

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Consider the entities below -



I need to order the Teams resultset such that the team with maximum active & unexpired skills comes first. I am using spring boot Specification & CriteriaQuery to filter Teams on different fields. So far I have the code below which doesn't work as expected.



Anything I am missing here? please suggest
 
Bartender
Posts: 2011
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe, try this:
 
Tapan Agarwal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himai Minh wrote:Maybe, try this:




Hi Himai, the code will only perform the join between Team and Employee, which I have already done in my code. I am unable to pull the total number of the skills of each team.
 
Himai Minh
Bartender
Posts: 2011
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about building a query like select count(distinct skills) from team_employee where team_employee is the joint table?
I am not  familiar with Specification though.
 
Tapan Agarwal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himai Minh wrote:How about building a query like select count(distinct skills) from team_employee where team_employee is the joint table?
I am not  familiar with Specification though.




I am stuck with Specification here since this is on an old code where I don't really have an option to change a lot of things.
 
Himai Minh
Bartender
Posts: 2011
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your toPredicate method, is it possible to use the criteria builder to build
a query like this one "select count( distinct skills) from Team_Employee "  where Team_Employee is the joint table ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic