求助?使用hql查询数据库时出现以下问题
javax.servlet.ServletException: No data type for node: org.hibernate.hql.ast.IdentNode
\-[IDENT] IdentNode: 'ordId ' {originalText=ordId}
代码:
public List getUserOrderList(int beginPage, int length,Integer userid) {
Session session = getSession();
Transaction tx = null;
tx = session.beginTransaction();
String hql = "from Orderlist o1,Orderpro o2 " +
"where o1.orderId = o2.ordId " +
"and o2.userId = " + userid+ ") ";
// 查询登录用户订单记录总数
Query query = session.createQuery( "select count(o1) " + hql);
rowCount = ((Integer) query.iterate().next()).intValue();
logger.info( "rowCount: " + rowCount);
this.setRowCount(rowCount);
// 查询所需页资料
query = session.createQuery( "from Orderlist ");
if (beginPage > 0) {
query.setFirstResult(length * (beginPage - 1));
}
query.setMaxResults(length);
List result = query.list();
tx.commit();
return result;
}
配置文件如下:
<?xml version= "1.0 "?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN "
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd ">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name= "com.founder.module.order.Orderpro " table= "orderpro " >
<id name= "id " type= "java.lang.Integer ">
<column name= "id " />
<generator class= "native " />
</id>
<property name= "ordId " type= "java.lang.Integer ">
<column name= "Ord_Id " not-null= "true " />
</property>
<property name= "userId " type= "java.lang.Integer ">
<column name= "UserId " not-null= "true " />
</property>