Hi,
I am trying to join two tables through a cross reference table using the Criteria API. The join is working fine until I try adding additional ON clauses.
The DB structure looks something like this:
role <==>
role_permission <==>
permissionWhen I try running the following code, I get an exception that says:
No value specified for parameter 2.Code:
Criteria criteria = session.createCriteria(Permission.class)
.createAlias("roles", "r", Criteria.LEFT_JOIN, Restrictions.eq("r.name", "ABC"));
Looking at the generated SQL confirms that the additonal ON clause is being added to both left join criteria, i.e.
Code:
select ... from permission p
left join role_permission rp on p.permision_id = rp.permision_id AND (r.role_name=?)
left join role r on rp.role_id = r.role_id AND (r.role_name=?)
What am I missing?
Thanks