Sleep Mode: Many-to-One Projection in Criteria
This is my first time dealing with the hibernate Criteria API.
I tried to do the equivalent of this HQL
"select t.userTbl from Task t"
The userTbl property is multivalued from the task. Task.userTbl relationships are 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 for HQL.
In HQL, although the userTbl relationship is set to lazy in display, HQL readily retrieves and materializes non-proxy UserTbl objects.
However, in the criteria, I get a list of proxies that I don't want. I worked with setFetchMode, but that didn't seem to be correct. Does anyone know how to properly accomplish the above in criteria and get non-proxies like HQL?
Thank.
+2
source to share
1 answer