读书人

对含有many-to-one外键的查询的有关问

发布时间: 2011-11-30 21:16:57 作者: rapoo

对含有many-to-one外键的查询的问题
<%
org.hibernate.Session s = HibernateSessionFactory.currentSession();
String hql = "from Xmb where dl=:dl order by xh asc ";
Lbb dl = (Lbb)s.get(Lbb.class, new Integer(1));
List list = s.createQuery(hql).setEntity( "dl ", dl).list();
Xmb xmb = null;
for (Iterator its = list.iterator(); its.hasNext(); ) {
xmb = (Xmb)(Object)its.next();
。。。。。(读数据)
}
HibernateSessionFactory.closeSession();
xmb = null;
list = null;
hql = null;
%>


报错:
org.hibernate.exception.SQLGrammarException: could not execute query
=========================

Lbb dl = (Lbb)s.get(Lbb.class, new Integer(1));是没有问题的,试验过,成功得到持久化类
不知出了什么问题?

[解决办法]
http://community.csdn.net/Expert/topic/4970/4970357.xml?temp=5.991763E-02

读书人网 >Java Web开发

热点推荐