我正在执行这个方法。
@Override
public Page<User> searchUsers(String name, int userTypeDefId, int accountTypeDefId,
final PageSetting pageSetting) {
HibernateCallback<Page<User>> hibernateCB = new HibernateCallback<Page<User>>() {
@Override
public Page<User> doInHibernate(Session session) throws HibernateException,
SQLException {
Criteria c = session.createCriteria(User.class);
DetachedCriteria dc = DetachedCriteria.forClass(UserType.class);
dc.setProjection(Projections.property("user"));
c.add(Subqueries.propertyEq(UserField.id.name(), dc));
c.addOrder(Order.asc(UserField.userName.name()));
Page<User> ret = getAll(c, pageSetting);
for (User user : ret.getData()) {
getHibernateTemplate().initialize(user.getUserAccountTypes());
getHibernateTemplate().initialize(user.getUserTypes());
}
return ret;
}
};
return getHibernateTemplate().execute(hibernateCB);
}
我有这个错误:
java.sql.SQLException: Subquery returns more than 1 row.
我是这种编程语言的新手,我对如何解决这个错误没有足够的想法。