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

Trouble Creating a Query Using Criteria

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • 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 ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
rahul khanna
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
forgot to add..
get the list from the criteria then
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic