项目框架 SpringMVC+Hibernate
开发工具 Myeclipse10
报错代码(下图):
检查项目发现出现问题的原因:配置文件有问题,少配置了一个字段,下面红色注释部分。
<fields>
a.id,a.title,a.author,a.content,a.source,a.createDate,a.releaseDate,(select name from BDic b where b.id=a.audit),(select name from BDic b where b.id=a.release),a.status,(select name from BDic b where b.id=a.type),b.id,c.id,d.id,a.newType,a.contentPicture,a.targetUrl,a.kind
</fields>
配置上缺少的字段,再次运行OK。
以下为部分完整代码段:
<query> <id>getList</id> <method>getList</method> <params> <param name="condition" type="java.util.Map"></param> <param name="sort" type="java.lang.String"></param> </params> <properties>id,title,author,content,source,createDate,releaseDate,audit,release,status,type,topic.id,channel.id,conference.id,newType,contentPicture,targetUrl,kind </properties> <fields>a.id,a.title,a.author,a.content,a.source,a.createDate,a.releaseDate,(select name from BDic b where b.id=a.audit),(select name from BDic b where b.id=a.release),a.status,(select name from BDic b where b.id=a.type),b.id,c.id,d.id,a.newType,a.contentPicture,a.targetUrl,a.kind </fields> <hql>from News a left join a.topic b left join a.channel c left join a.conference d </hql> <conditions> <condition id="id" describe="id"> <params type="param"> <param name="id" type="java.lang.String"></param> </params> <hql>a.id = ?</hql> </condition> <condition id="title" describe=""> <params type="param"> <param name="title" type="java.lang.String" /> </params> <hql>a.title like ?</hql> </condition> <condition id="author" describe=""> <params type="param"> <param name="author" type="java.lang.String" /> </params> <hql>a.author like ? </hql> </condition> <condition id="source" describe=""> <params type="param"> <param name="source" type="java.lang.String" /> </params> <hql>a.source like ? </hql> </condition> <condition id="audit" describe=""> <params type="param"> <param name="audit" type="java.lang.String" /> </params> <hql>a.audit like ? </hql> </condition> </conditions> <group></group> <order></order> <className>cn.digitalpublishing.po.News</className> </query>