I have one class Bar with a primary key composed of a 'key-many-to-one' to a class Foo.
I want to find a Bar instance with a Foo id so I have this criteria :
Criteria criteria = session.createCriteria(Bar.class);
criteria.createCriteria("foo").add(Expression.eq("id", new Integer(1)));
Bar bar = (Bar) criteria.uniqueResult();
Then I have this sql statement
select this.ID_FOO as ID_FOO0_, this.text as text0_ from BAR this where x0_.id=1
which fails because x0_ isn't defined.
With an HQL query it works.
SQLServer with jTds driver