jQuery in Action, 2nd edition
The moose likes Object Relational Mapping and the fly likes Criteria API Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Criteria API" Watch "Criteria API" New topic
Author

Criteria API

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
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.


Appendix
--------

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.



Tony Morris
Java Q&A (FAQ, Trivia)
 
 
subject: Criteria API
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com