• Post Reply Bookmark Topic Watch Topic
  • New Topic

Criteria API  RSS feed

Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following relational mapping:
"A Property has an Address which has a Postcode which has a locality (of type String)".
These relationships are mapped using a many-to-one.
I'm trying to construct a query to select Property types by using the Criteria API (Chapter 12 of the Reference)
and specifying a value for the postcode. All of my attempts so far have failed.

Here is an example of what I am trying to achieve unsuccessfully:

This results in the following error:

net.sf.hibernate.QueryException: could not resolve property: postcode.locality of: com.tmits.web.re.dao.Address.

I've tried everything that I can think of to achieve a solution.
Assistance is most appreciated.


Using XDoclet, the code looks something like the following.
It has been trimmed for brevity (this question is already long) but effort has made to not trim appropriate parts.
If anyone feels it is appropriate to construct a complete test case and leave it unaltered, I will do so.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!