It looks like the generated sql query is wrong. I tried a simple example with two entities (EntityA and EntityB). EntityA has a many-to-many relationship to EntityB.
The criteria:
Criteria criteria = session.createCriteria(EntityA.class); criteria.createAlias("entites", "entity", JoinType.INNER_JOIN, Restrictions.eq("some_condition", true)); criteria.list();
The generated sql query:
select * from EntityA this_ inner join JoinTable jt on this_.id=jt.entity_a_id and ( entityB.some_condition=? ) inner join EntityB entityB on jt.entity_b_id=entityB.id and ( entityB.some_condition=? )
Hibernate should NOT add the on-clause to the first join. Even if the parameter values were specified properly it would result in a "Unknown column 'entityB.some_condition' in 'on clause'" error.
The error message ("No value specified for parameter 1.") is somewhat misleading in this case. Hibernate provides only one value for the on-clause but added the on-clause twice. Therefore the error about missing values.
I think the problem is somewhere in the JoinWalker, but I dont think I can provide a proper fix / pull-request, so hopefully someone else can take over from here...
Hibernate version: 4.2.4.Final
|