我在 Hibernate 中为复合键使用 Detached Criteria 的投影。在尝试创建别名时,我收到错误消息:
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: businessId of
如果有人可以建议如何在 Hibernate 中投射复合键的值,我将不胜感激。
我的代码是:
public class GridOffProviderExHibernateSpringDAO extends HibernateDaoSupport implements GridOffProviderExDAO {
private Session session;
@SuppressWarnings("unchecked")
public List<Object[]> findProviderSummariesByOffProviderId(List<Object[]> offProvIds, int firstResult, int maxResults) {
DetachedCriteria offProvCrit = DetachedCriteria.forClass(GridOffProvider.class)
.createAlias("provider", "providerAlias", Criteria.LEFT_JOIN)
.createAlias("office", "officeAlias", Criteria.LEFT_JOIN)
.createAlias("office.business.primaryKey","officeAliaspk",Criteria.LEFT_JOIN);
ProjectionList offProviderProjList = Projections.projectionList();
offProviderProjList.add(Projections.property( offProviderProjList.add(Projections.groupProperty("officeAliaspk" + "." + GridOffProviderPkDAO.OFFICE_ID));
offProviderProjList.add(Projections.groupProperty(GridOffProviderDAO.OFF_PROVIDER_SID));
offProviderProjList.add(Projections.groupProperty(GridOffProviderDAO.END_DATE));
offProviderProjList.add(Projections.groupProperty("providerAlias" + "." + GridProviderDAO.FIRST_NAME));
offProviderProjList.add(Projections.groupProperty("providerAlias" + "." + GridProviderDAO.LAST_NAME));
offProvCrit.setProjection(offProviderProjList);
offProvCrit.add(Subqueries.propertyEq("businessId", offProvCrit));
offProvCrit.add(Restrictions.in(GridOffProviderDAO.OFF_PROVIDER_SID, offProvIds));
return findByCriteria(offProvCrit, firstResult, maxResults);
}