Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help With Hibernate Criteria Query

 
Jason Ferguson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following class:



I want to write a query (preferably criteria) that will tell me if the user has no assigned items (assignedItems.size() == 0).

So here is the start of my my method:



This is probably simple, but the answer is eluding me. Any help?

Jason
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like Restrictions.isEmpty("assignedItems")
 
Jason Ferguson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, that's one way... but I need to expand upon this for other assigned items.

Here is a definition of the Item class:



ItemType will be a class:



So my next query will be needing to know something like which users have more than one monitor (Monitor being an ItemType).

Unfortunately, QueryByExample NEVER works right for me, so I prefer Criteria, or, if necessary, HQL.

Jason
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic