日期:2014-05-18  浏览次数:20671 次

对含有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