Hi all,
I have been using the criteria API for a few weeks now and it is working great, but I am having one relatively serious problem that I don't see addressed in any documents or examples so far. I can only use the Criteria API to go one association level deep in the object graph. For example I have the following tables. For instance given the following tables...
Code:
-- This is obvious DDL pseudocode, but you get the idea...
create table user(
user_pk,
name ,
create_date,
user_role_fk
);
create table user_role(
user_role_pk,
role_name,
location_fk
)
create table location
(
location_pk,
location_name
)
I can procedurally create queries to return users by the properties user.* and user.user_role.* with the following code:
Code:
Criteria crit = session.createCriteria(User.class);
crit.createCriteria("user_role", "ur");
crit.createCriteria("ur.location" "loc");
this will create a SQL statement and the appropriate joins. The first 2 createCriteria calls work fine, but the third statement throws an error similar to
Code:
net.sf.hibernate.QueryException: could not resolve property: ur.location of: myPackage.User
The error makes perfect sense to me and I realize I am probably doing something wrong. But for the life of me I can't figure out how to achieve this functionality. Is there any way to do this or is this a limitation of the API?
Thanks,
Rob