Hi all,
I am playing around with the hibernate Criteria API for the first time recently.
I was trying to do the equivalent of this HQL
"select t.userTbl from Task t"
userTbl property is a many-to-one from Task. The Task.userTbl relationship is lazy.
So I came up with this
Criteria criteria = session.createCriteria( Task.class, "t" );
criteria.setProjection( Projections.property( "t.userTbl" ) );
List results = criteria.list();
Unfortunately this does something different to HQL.
In HQL although the userTbl relationship is set to lazy in the mapping the HQL eagerly fetches and materialises non-proxy objects of UserTbl.
However in the Criteria I get a list of proxies back which I don't want. I fiddled around with setFetchMode but this didn't seem to be the right thing. Anyone have any idea how to do the above in a Criteria properly and get non-proxies back like HQL?
Thanks.