我需要从相关表中获取所有数据,所以我使用这样的东西(我会在 sql 中使用它)
private static final String SELECT_OOPR_TO_SEND = "SELECT R.* " +
"FROM offerOrderProjectRel R, offerOrder O, project P " +
"WHERE P.id = R.project_id and O.id = R.offer_order_id " +
"and O.type = 'ORDER' and (P.status = 'PENDING' or P.status ='PROTECTED')" ;
;
@SuppressWarnings("unchecked")
public List<OfferOrderProjectRel> findAllOfferOrderToSendToSalesmans() {
Query q = getSession().createQuery(SELECT_OOPR_TO_SEND);
List<OfferOrderProjectRel> list = q.list();
return list;
}
启动此代码后,我收到该错误:
org.hibernate.hql.internal.ast.QuerySyntaxException:期待 IDENT,在第 1 行第 10 列附近找到“**”[SELECT R.* FROM offerOrderProjectRel R,offerOrder O,项目 P WHERE P.id = R.project_id 和 O .id = R.offer_order_id and O.type = 'ORDER' and (P.status = 'PENDING' or P.status ='PROTECTED')]
那么如何使用休眠模式从 R 列获取所有数据?