日期:2014-05-17  浏览次数:21477 次

帮忙看下这段hsql语句吧
Java code

session.createQuery("count(e.emails) from Employee e where e.email = :eml").setString("eml", e.getEmail()).uniqueResult();






说明一下,Employee这个类中有一个集合类型是Email类型的,他们是多对多的关系,现在我想要拿出Employee中得emails的总数,我这么些hsql语句后报错了如下错误:

java.sql.SQLSyntaxErrorException: ORA-00936: 缺失表达式

oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:785)
oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:860)
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3425)
oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1490)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
org.hibernate.loader.Loader.doQuery(Loader.java:697)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
org.hibernate.loader.Loader.doList(Loader.java:2232)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
org.hibernate.loader.Loader.list(Loader.java:2124)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)
com.alan.easyoa.dao.impl.EmailDaoImpl$1.doInHibernate(EmailDaoImpl.java:67)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
com.alan.easyoa.dao.impl.EmailDaoImpl.getEmailsInInbox(EmailDaoImpl.java:47)
com.alan.easyoa.service.impl.EmailServiceImpl.getEmailInbox(EmailServiceImpl.java:43)
sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.interceptor.ExposeInvocatio