2 u014453569 u014453569 于 2016.05.04 10:21 提问

关于hibernate查询问题!急!在线等!!!!!!!!!!!!!!!!!!!
//根据解压出来的文件查找文件夹名和截取出来的字符串相同的且层级比当前文件层级小1的文件夹(所属同一个解压文件)
    @SuppressWarnings("unchecked")
    public List<DpFolders> findByDpDocuments(String dpfname, int fileLevel, Documents documents) {
        System.out.println("进入方法进行查找");
        return super.getHibernateTemplate().find("from DpFolder where dpfname="+dpfname+"and fileLevel="+fileLevel+"and documents_id="+documents.getDid());
    }

会报错:
Struts Problem Report

Struts has detected an unhandled exception:
Messages:

unexpected token: fileLevel near line 1, column 41 [from DpFolder where dpfname=__MACOSXand fileLevel=0and documents_id=1334]
unexpected token: fileLevel near line 1, column 41 [from DpFolder where dpfname=__MACOSXand fileLevel=0and documents_id=1334]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: fileLevel near line 1, column 41 [from DpFolder where dpfname=__MACOSXand fileLevel=0and documents_id=1334]

File: org/hibernate/hql/ast/QuerySyntaxException.java
Line number: 54
Stacktraces
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: fileLevel near line 1, column 41 [from DpFolder where dpfname=__MACOSXand fileLevel=0and documents_id=1334]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: fileLevel near line 1, column 41 [from DpFolder where dpfname=__MACOSXand fileLevel=0and documents_id=1334]

org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)
com.know.dao.DocumentsDaoImp.findByDpDocuments(DocumentsDaoImp.java:108)
com.know.service.DocumentsServiceImp.findByDpDocuments(DocumentsServiceImp.java:91)
com.know.action.DocumentsAction.decompression(DocumentsAction.java:263)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

2个回答

abcdhcy8
abcdhcy8   2016.05.04 10:29

and前面加个空格。。。

CSDNXIAOD
CSDNXIAOD   2016.05.04 10:32

hibernate 离线查询 在线查询
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!