Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting started with HQL - how to query on sets?

 
Erik Blank
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving from Criteria to HQL and enjoying the process, but have a a question.

I have a class "Person" with a one-to-many set of objects "Metadata". Metadata are simple objects; they only have a String key and a String value.

I would like to use HQL to query for person objects based on multiple metadata constraints.

For example, I want to find people objects with two types of specific types of metadata.



This doesn't return anything, even though there are people objects with red hair and green eyes in my database....

This is probably because I am asking for a specific metadata object's value ("key") to be two things at the same time.

If I use an 'or', I get results back, but I want red-haired green-eyed people specifically.

How should I express my desire to search though a set this way? Thanks.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!