Hibernate version: 3.1.3
AuthorizationXml has a many to one relationship with MemberXml
We are having a problem translating the following HQL to the criteria API:
The query selects back auths restricting them by the member's ID:
Code:
List <AuthorizationXml> lResults = getHibernateTemplate().findByNamedParam(
"select auth from AuthorizationXml auth " +
"join auth.member mem " +
"where mem.memberId like :pMemberId",
new String[] {"pMemberId"},
new Object[] {pCriteria.getMemberId()});
Now trying this with the criteria API:
Code:
Criteria lAuthCrit = getSession()
.createCriteria(AuthorizationXml.class)
.createAlias("member", "mem");
lAuthCrit = lAuthCrit.add(Restrictions.like("mem.memberId", pCriteria.getMemberId()));
List<AuthorizationXml> lResults = lAuthCrit.list();
The above code selects back both the auth and the member record. I do not want to fetch the member record, I merely want to restrict by it.
We have tried all varieties of setFetchMode on the member association and the net result has been the same. Is this a bug or are we doing something wrong.
Thanks.
Tyler Van Gorder
tkv@landacorp.com
Landacorp.