• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trouble Creating a Query Using Criteria

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I'm trying to get a list of records from a table that meet a certain criteria and I'm having difficulty getting the Hibernate code correct. Here's what I have:



There's a table in my database named "Reviewer" which has a foreign key relationship with "ReviewerRole". There are obviously more fields in these objects, but these are really the only ones I care about. The Hibernate mapping seems to be working properly as when I do this:



I get a full list back and the ReviewerRole object is populated for every Reviewer.

What I want to do is essentially this:



I originally started with this:



When I try to run that, though, I get this error:


org.hibernate.QueryException: could not resolve property role.roleDescription of: ...Reviewer


Any thoughts? In looking at the documentation I can find, I'm not sure why this doesn't work, but the dereferencing of "role" doesn't seem to be working. Any advice is much appreciated.

Thanks,
Corey
[ June 11, 2008: Message edited by: Corey McGlone ]
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it



or is it



or is it



-Cameron
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is "role.roleDescription" and a co-worker of mine came up with this solution:



Honestly, since I already had this query working with HQL, I haven't even tried this to see if it works, but I assume it does.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this
change properties/object names as you need
 
rahul khanna
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
forgot to add..
get the list from the criteria then
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic