问题描述
我在执行单元测试时遇到了一个Hibernate问题,这是我得到的问题:
springframework.dao.InvalidDataAccessResourceUsageException:用户缺少权限或找不到对象:ROWNUM; SQL [n / a];
嵌套异常是org.hibernate.exception.SQLGrammarException:
用户缺少权限或找不到对象:ROWNUM
....
导致:org.hsqldb.HsqlException:
用户缺少权限或找不到对象:ROWNUM
< hibernate.version> 4.1.0.Final< /hibernate.version>
$ b
< hsqldb.version> 2.3.3< /hsqldb.version>
我正在测试的函数在生产环境中完美工作,但我不知道为什么在测试它时不是这种情况。
以下是引发错误的测试函数:
@Override
public评估标准findByCriteriaIdAndEvaluationId(长评估ID,长标准ID){
JPAQuery query = new JPAQuery(getEntityManager());
QEvaluationCriteria evaluationCriteria = QEvaluationCriteria.evaluationCriteria;
返回query.from(evaluationCriteria)
.where(evaluationCriteria.evaluation.id.eq(evaluationId))
.where(evaluationCriteria.criteria.id.eq(criteriaId) )
.singleResult(evaluationCriteria);
}
我的测试:
@Test
public void findByCriteriaIdAndEvaluationId(){
long evaluationId =(long)1;
Long criteriaId =(long)1;
EvaluationCriteria结果= null;
result = evaluationCriteriaDAO.findByCriteriaIdAndEvaluationId(evaluationId,criteriaId);
Assert.assertNotNull(result);
}
我的实体如下所示:
@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name =SFINX_EVALUATION_CRITERIA,uniqueConstraints = @UniqueConstraint(columnNames = {CRITERIA_ID,EVALUATION_ID}))
public class EvaluationCriteria implements Identifiable< Long> {
private static final long serialVersionUID = 6254229189011963873L;
private static final String SEQ_GENERATOR_NAME =EvaluationCriteriaSeq;
私人长ID;
私有标准条件;
私人评估评估;
$ b $ @Override
@Id
@SequenceGenerator(name = SEQ_GENERATOR_NAME,initialValue = 1,sequenceName =SFINX_EVALUATION_CRITERIA_SEQ,allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = SEQ_GENERATOR_NAME)
@Column(name =ID,updatable = false)
public Long getId(){
return id;
}
public void setId(Long id){
this.id = id;
@ManyToOne(fetch = FetchType.LAZY,targetEntity = Criteria.class)
@JoinColumn(name =CRITERIA_ID,nullable = false)
public条件getCriteria(){
返回条件;
}
public void setCriteria(Criteria criteria){
this.criteria = criteria;
@ManyToOne(fetch = FetchType.LAZY,targetEntity = Evaluation.class)
@JoinColumn(name =EVALUATION_ID,nullable = false)
public评估getEvaluation(){
返回评估;
}
public void setEvaluation(评估评估){
this.evaluation = evaluation;
我的Persistence看起来像这样:
<?xml version =1.0encoding =UTF-8?>
< persistence version =2.0
xmlns =http://java.sun.com/xml/ns/persistencexmlns:xsi =http://www.w3.org/ 2001 / XMLSchema-instance
xsi:schemaLocation =http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd >
< persistence-unit name =testDaoUnittransaction-type =RESOURCE_LOCAL>
< provider> org.hibernate.ejb.HibernatePersistence< / provider>
< class> org.springframework.ldap.core.LdapTemplate< / class>
< class> net.gdcw.sfinx.domain.Employee< / class>
< class> net.gdcw.sfinx.domain.Criteria< / class>
< class> net.gdcw.sfinx.domain.CriteriaType< / class>
< class> net.gdcw.sfinx.domain.CriteriaTypeItem< / class>
< class> net.gdcw.sfinx.domain.EmployeeEvaluation< / class>
< class> net.gdcw.sfinx.domain.Evaluation< / class>
< class> net.gdcw.sfinx.domain.EvaluationCriteria< / class>
< class> net.gdcw.sfinx.domain.Feedback< / class>
< class> net.gdcw.sfinx.domain.Project< / class>
< class> net.gdcw.sfinx.domain.ProjectEmployee< / class>
< class> net.gdcw.sfinx.domain.Role< / class>
< class> net.gdcw.sfinx.domain.SystemRole< / class>
< class> net.gdcw.sfinx.domain.ImprovementProposal< / class>
< class> net.gdcw.sfinx.domain.Department< / class>
< shared-cache-mode> ENABLE_SELECTIVE< / shared-cache-mode>
<属性>
< property name =hibernate.dialectvalue =org.hibernate.dialect.Oracle10gDialect/>
< property name =hibernate.show_sqlvalue =true/>
< property name =format_sqlvalue =true/>
< property name =hibernate.hbm2ddl.autovalue =create/>
< property name =use_sql_commentsvalue =true/>
<! - 缓存属性 - >
< property name =hibernate.cache.use_second_level_cachevalue =true/>
< property name =show_sqlvalue =true/>
< property name =hibernate.cache.use_query_cachevalue =true/>
< property name =hibernate.cache.region.factory_class
value =org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory/>
< property name =net.sf.ehcache.configurationResourceNamevalue =META-INF / ehcache.xml/>
< / properties>
< / persistence-unit>
< /持久性>
最后,完整的堆栈跟踪:
休眠:删除表SFINX_CRITERIA级联约束
休眠:删除表SFINX_CRITERIA_TYPE级联约束
休眠:删除表SFINX_CRITERIA_TYPE_ITEM级联约束
休眠:删除表SFINX_DEPARTMENT级联限制
休眠:DROP TABLE SFINX_EMPLOYEE级联约束
休眠:DROP TABLE SFINX_EMPLOYEE_EVALUATION级联约束
休眠:DROP TABLE SFINX_EMPLOYEE_SYSTEM_ROLE级联约束
休眠:DROP TABLE SFINX_EVALUATION级联约束
休眠:drop table SFINX_EVALUATION_CRITERIA级联约束
Hibernate:drop table SFINX_EVALUATION_MANAGER级联约束
Hibernate:drop table SFINX_EVALUATION_VIEWER级联约束
Hibernate:drop table SFINX_FEEDBACK级联约束
Hibernate:drop table SFINX_IMPROVEMENT_PROPOSAL级联约束
Hibernate :DROP TABLE SFINX_PROJECT级联约束
休眠:DROP TABLE SFINX_PROJECT_EMPLOYEE级联约束
休眠:DROP TABLE SFINX_ROLE级联约束
休眠:DROP TABLE SFINX_SYSTEM_ROLE级联约束
休眠:降序列SFINX_CRITERIA_SEQ
Hibernate:删除序列SFINX_CRITERIA_TYPE_ITEM_SEQ
Hibernate:删除序列SFINX_CRITERIA_TYPE_SEQ
Hibernate:删除序列SFINX_DEPARTMENT_SEQ
Hibernate:删除序列SFINX_EMPLOYEE_EVALUATION_SEQ
Hibernate:删除序列SFINX_EMPLOYEE_SEQ
Hibernate:drop序列SFINX_EVALUATION_CRITERIA_SEQ
Hibernate:删除序列SFINX_EVALUATION_SEQ
Hibernate:删除序列SFINX_FEEDBACK_SEQ
Hibernate:删除序列SFINX_IMPROVEMENT_PROPOSAL_SEQ
Hibernate:删除序列SFINX_PROJECT_EMPLOYEE_SEQ
Hibernate:删除序列SFINX_PROJECT_SEQ
Hibernate:删除序列SFINX_ROLE_SEQ
Hibernate:删除序列SFINX_SYSTEM_ROLE_SEQ
Hibe rnate:创建表SFINX_CRITERIA(ID号(19,0)不为空,CREATE_DATE时间戳不为空,UPDATE_DATE时间戳不为空,DELETED char(1个字符),描述varchar2(1000个字符),名称varchar2(255个字符)非空,CRITERIA_TYPE_ID数字(19,0)不为空,主键(ID),唯一(NAME))
Hibernate:创建表SFINX_CRITERIA_TYPE(ID号(19,0)不为空,名称varchar2(255 char)主键(ID),唯一(NAME))
Hibernate:创建表SFINX_CRITERIA_TYPE_ITEM(ID号(19,0)不为空,VALUE varchar2(255 char)非空,CRITERIA_TYPE_ID号(19,0)非空,主键(ID),唯一(CRITERIA_TYPE_ID,VALUE))
Hibernate:创建表SFINX_DEPARTMENT(ID号(19,0)不为空,名称varchar2(255 char)不为null,主键(ID) NAME))
Hibernate:创建表SFINX_EMPLOYEE(ID号(19,0)不为空,ARCHIVED char(1个字符),EMAIL varchar2(255个字符),FIRST_NAME varchar2(255个字符),LAST_NAME varchar2(255个字符) ,LOGIN varchar2(255 char)不为null唯一的DEPARTMENT_ID号(19,0),主键(ID),唯一的(LOGIN))
Hibernate:创建表SFINX_EMPLOYEE_EVALUATION(ID号(19,0)不为空,CREATE_DATE时间戳不为空,UPDATE_DATE时间戳不为空,EMPLOYEE_ID号(19,0)不为空,EVALUATION_ID号(19,0)不为空,PROJECT_ID号(19,0)不为空,主键(ID),唯一性(EVALUATION_ID,EMPLOYEE_ID,PROJECT_ID))
Hibernate:创建表SFINX_EMPLOYEE_SYSTEM_ROLE(EMPLOYEE_ID号(19,0)不为空,SYSTEM_ROLE_ID号(19,0)不为空)
Hibernate:创建表SFINX_EVALUATION(ID号(19,0)不为空,CREATE_DATE时间戳不为空,UPDATE_DATE时间戳不为空,CLOSURE_DATE时间戳,DELETED char(1个字符),说明varchar2(1000个字符),END_DATE时间戳,NAME varchar2(255个字符)非空,START_DATE时间戳,STATUS varchar2(255个字符),MASTER_ID数字(19, 0)不为空,主键(ID),唯一(NAME))
Hibernate:创建表SFINX_EVALUATION_CRITERIA(ID号(19,0)不为空,CRITERIA_ID n (19,0)不为空,EVALUATION_ID号(19,0)不为空,主键(ID),唯一的(CRITERIA_ID,EVALUATION_ID))
Hibernate:创建表SFINX_EVALUATION_MANAGER(EVALUATION_ID number(19,0)not Hibernate:create table SFINX_EVALUATION_VIEWER(EVALUATION_ID number(19,0)not null,VIEWER_ID number(19,0)not null)
Hibernate:create table SFINX_FEEDBACK(ID号(19,0)不为空,CREATE_DATE时间戳不为空,UPDATE_DATE时间戳不为空,COMMENTS varchar2(1000 char),RELEASED char(1 char),VALUE varchar2(255 char),EMPLOYEE_EVALUATION_ID number(19,0)不为空,EMPLOYEE_ID数(19,0)不为空,EVALUATION_CRITERIA_ID数(19,0)不为空,主键(ID),唯一的(EMPLOYEE_ID,EMPLOYEE_EVALUATION_ID,EVALUATION_CRITERIA_ID))
休眠:创建表SFINX_IMPROVEMENT_PROPOSAL(ID号码(19,0)不为空,PROPOSAL varchar2(1000字符)不为空,EMPLOYEE_ID号(19,0)不为空,主键(ID))
Hibernate:创建表SFI NX_PROJECT(ID号(19,0)非空,CLIENT_NAME varchar2(255个字符),DELETED char(1个字符),END_DATE时间戳不为空,NAME varchar2(255个字符)非空,START_DATE时间戳不为空,WBS varchar2(255个字符),主键(ID),唯一(NAME))
Hibernate:创建表SFINX_PROJECT_EMPLOYEE(ID号(19,0)非空,EMPLOYEE_ID号(19,0)非空,PROJECT_ID号(19,0) ,ROLE_ID号(19,0)不为空,主键(ID),唯一的(EMPLOYEE_ID,PROJECT_ID))
Hibernate:创建表SFINX_ROLE(ID号(19,0)不为空,DELETED char(1个字符) ,NAME varchar2(255 char),主键(ID),唯一(NAME))
Hibernate:创建表SFINX_SYSTEM_ROLE(ID号(19,0)不为空,DELETED char(1个字符),NAME varchar2(255焦炭)不空,主键(ID),唯一的(名))
休眠:ALTER TABLE SFINX_CRITERIA添加约束FKA3B6A81EED06FF7E外键(CRITERIA_TYPE_ID)引用SFINX_CRITERIA_TYPE
休眠:ALTER TABLE SFINX_CRITERIA_TYPE_ITEM添加约束FKEE5DAE17ED 06FF7E外键(CRITERIA_TYPE_ID)引用SFINX_CRITERIA_TYPE
Hibernate:alter table SFINX_EMPLOYEE添加约束FK767FAF6D15CF1A9F外键(DEPARTMENT_ID)引用SFINX_DEPARTMENT
Hibernate:alter table SFINX_EMPLOYEE_EVALUATION添加约束FK1BC4A34ECDBE9A5F外键(EVALUATION_ID)引用SFINX_EVALUATION
休眠:ALTER TABLE SFINX_EMPLOYEE_EVALUATION添加约束FK1BC4A34EE55C6715外键(PROJECT_ID)引用SFINX_PROJECT
休眠:ALTER TABLE SFINX_EMPLOYEE_EVALUATION添加约束FK1BC4A34EB756525F外键(EMPLOYEE_ID)引用SFINX_EMPLOYEE
休眠:ALTER TABLE SFINX_EMPLOYEE_SYSTEM_ROLE添加约束FKD0BCA2B4500008DE外键(SYSTEM_ROLE_ID )引用SFINX_SYSTEM_ROLE
休眠:ALTER TABLE SFINX_EMPLOYEE_SYSTEM_ROLE添加约束FKD0BCA2B4B756525F外键(EMPLOYEE_ID)引用SFINX_EMPLOYEE
休眠:ALTER TABLE SFINX_EVALUATION添加约束FKFE79983B8D73022B国外ķ (MASTER_ID)引用SFINX_EMPLOYEE
Hibernate:alter table SFINX_EVALUATION_CRITERIA添加约束FKCA237AE3CDBE9A5F外键(EVALUATION_ID)引用SFINX_EVALUATION
Hibernate:alter table SFINX_EVALUATION_CRITERIA添加约束FKCA237AE394A3C8BF外键(CRITERIA_ID)引用SFINX_CRITERIA
Hibernate:修改表SFINX_EVALUATION_MANAGER添加约束FK2C4B6F89CDBE9A5F外键(EVALUATION_ID)引用SFINX_EVALUATION
休眠:ALTER TABLE SFINX_EVALUATION_MANAGER添加约束FK2C4B6F8915931500外键(MANAGER_ID)引用SFINX_EMPLOYEE
休眠:ALTER TABLE SFINX_EVALUATION_VIEWER添加约束FK5346E296CDBE9A5F外键(EVALUATION_ID)引用SFINX_EVALUATION
Hibernate:alter table SFINX_EVALUATION_VIEWER添加约束FK5346E296236B9C7B外键(VIEWER_ID)引用SFINX_EMPLOYEE
Hibernate:alter table SFINX_FEEDBACK添加约束FK23F2B44486766958外键(EVALUATION_CRITERIA_ID)re ferences SFINX_EVALUATION_CRITERIA
休眠:ALTER TABLE SFINX_FEEDBACK添加约束FK23F2B444B756525F外键(EMPLOYEE_ID)引用SFINX_EMPLOYEE
休眠:ALTER TABLE SFINX_FEEDBACK添加约束FK23F2B444CE47D6DC外键(EMPLOYEE_EVALUATION_ID)引用SFINX_EMPLOYEE_EVALUATION
休眠:ALTER TABLE SFINX_IMPROVEMENT_PROPOSAL添加约束FK49CA2A9AB756525F外键(EMPLOYEE_ID)引用SFINX_EMPLOYEE
Hibernate:alter table SFINX_PROJECT_EMPLOYEE添加约束FKE09FA2F3E55C6715外键(PROJECT_ID)引用SFINX_PROJECT
Hibernate:alter table SFINX_PROJECT_EMPLOYEE添加约束FKE09FA2F3BBCC17DF外键(ROLE_ID)引用SFINX_ROLE
Hibernate:alter table SFINX_PROJECT_EMPLOYEE添加约束FKE09FA2F3B756525F外键(EMPLOYEE_ID)引用SFINX_EMPLOYEE
Hibernate:创建序列SFINX_CRITERIA_SEQ
Hibernate:创建序列SFINX_CRITERIA_TYPE_ITEM_SEQ
Hibernate:create se quence SFINX_CRITERIA_TYPE_SEQ
Hibernate:创建序列SFINX_DEPARTMENT_SEQ
Hibernate:创建序列SFINX_EMPLOYEE_EVALUATION_SEQ
Hibernate:创建序列SFINX_EMPLOYEE_SEQ
Hibernate:创建序列SFINX_EVALUATION_CRITERIA_SEQ
Hibernate:创建序列SFINX_EVALUATION_SEQ
Hibernate:创建序列SFINX_FEEDBACK_SEQ
Hibernate:创建序列SFINX_IMPROVEMENT_PROPOSAL_SEQ
Hibernate:创建序列SFINX_PROJECT_EMPLOYEE_SEQ
Hibernate:创建序列SFINX_PROJECT_SEQ
Hibernate:创建序列SFINX_ROLE_SEQ
Hibernate:创建序列SFINX_SYSTEM_ROLE_SEQ
测试运行:4,失败:0,错误:1,跳过:0,经过的时间:0.056秒<<失败!
findByCriteriaIdAndEvaluationId(net.gdcw.sfinx.dao.EvaluationCriteriaDaoTest)经过的时间:0.026秒<<<错误!
org.springframework.dao.InvalidDataAccessResourceUsageException:用户缺少权限或找不到对象:ROWNUM; SQL [n / a];嵌套异常是org.hibernate.exception.SQLGrammarException:用户缺少特权或找不到对象:ROWNUM
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:231)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:214)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
at org。 springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
处的org.springframework.dao org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
。 support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.p roceed(ReflectiveMethodInvocation.java:179)
在org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
。在com.sun.proxy。$ Proxy47.findByCriteriaIdAndEvaluationId(来源不明)
在net.gdcw.sfinx.dao.EvaluationCriteriaDaoTest.findByCriteriaIdAndEvaluationId(EvaluationCriteriaDaoTest.java:45)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
。在sun.reflect.NativeMethodAccessorImpl。调用(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
在org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
在org.junit.internal.runners。 statements.InvokeMethod.evaluate(InvokeMethod.java:17)
处org.springframework.test org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:72)
。 context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:81)
在org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
。在组织。 junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
处org.springframework.test org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:216)
。 context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:82)
。在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:238)
。在1 org.junit.runners.ParentRunner $。日程安排(ParentRunner.java:63)
在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
在org.junit.run ners.ParentRunner.access $ 000(ParentRunner.java:53)
在org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:229)
在org.springframework.test.context.junit4。 statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60)
处org.junit.runners org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:67)
。 ParentRunner.run(ParentRunner.java:309)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:162)
位于org.apache.maven.surefire.junit4。 JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4。 JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Nat iveMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
在org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory $ ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
在org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
引起:org.hibernate.exception.SQLGrammarException:用户缺少权限或对象未找到: ROWNUM
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:83)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.conver t(StandardSQLExceptionConverter.java:49)
位于org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
位于org.hibernate.engine.jdbc.spi.SqlExceptionHelper。在org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:146)上转换(SqlExceptionHelper.java:110)
org.hibernate.engine.jdbc.internal中的
。 proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy。$ Proxy57.prepareStatement(Unknown Source)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl $ 5.doPrepare (StatementPreparerImpl.java:147)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl $ StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl .prepareQueryStatement(StatementPreparerImpl.java:145)$ or $ $ b $ org.hibernate.loader.Loader.prepareQueryStatement(Loader.java :1720)
at org.hibernate.loader.Loader.doQuery(Loader.java:828)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2447)
在org.hibernate.loader.Loader.doList(Loader.java:2433)
在org.hibernate.loader.Loader。 listIgnoreQueryCache(Loader.java:2263)
在org.hibernate.loader.Loader.list(Loader.java:2258)
在org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java: 470)
在org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:
)org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1161)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.internal.SessionImpl.list .hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:280)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
。在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke (Method.java:606)
at org.springframework.orm.jpa.SharedEntityManagerCreator $ DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:360)
at com.sun.proxy。$ Proxy56.getSingleResult(Unknown Source )
at com.mysema.query.jpa.impl.AbstractJPAQuery.getSingleResult(AbstractJPAQuery.java:245)
at com.mysema.query.jpa.impl.AbstractJPAQuery.uniqueResult(AbstractJPAQuery.java:323 )
at com.mysema.query.jpa.impl.AbstractJPAQuery.uniqueResult(AbstractJPAQuery.java:308)
at com.mysema.query.support.ProjectableQuery.singleResult(ProjectableQuery.java:150)
at net.gdcw.sfinx.dao.EvaluationCriteriaDAOImpl.findByCriteriaIdAndEvaluationId(EvaluationCriteriaDAOImpl.java:40)
at sun.reflect.NativeMethodAc cessorImpl.invoke0(本机方法)
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
。在java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop。 framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
处org.springframework.dao.support.PersistenceExceptionTranslationInterceptor org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
。 invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 39 more
导致:java.sql.SQLSyntaxErrorException:用户缺少权限或找不到对象:ROWNUM
at org。 hsqldb.jdbc.JDBCUtil.sqlException(未知源)
在org.hsqldb.jdbc.JDB在org.hsqldb.jdbc.JDBCConnection.prepareStatement(未知源)
(未知源)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
... 76 more
引起:org.hsqldb.HsqlException:用户缺少权限或对象未找到:ROWNUM
在org.hsqldb.error.Error.error(未知源)
在org.hsqldb.error.Error.error(未知源)
在org.hsqldb.ExpressionColumn.checkColumnsResolved(未知源)
在org.hsqldb.QueryExpression.resolve(Unkno wn源)
在org.hsqldb.ParserDQL.compileCursorSpecification(未知源)
在org.hsqldb.ParserCommand.compilePart(未知源)
在org.hsqldb.ParserCommand.compileStatement(未知来源)
在org.hsqldb.Session.compileStatement(未知来源)
在org.hsqldb.StatementManager.compile(未知来源)
在org.hsqldb.Session.execute(未知来源)
... 83 more
我主要关心这个问题:
- 完美的制作工作
- 完全没有像
ROWNUM
在我的所有代码中。
所以我基本上不明白Hibernate想告诉我什么^^。
提前感谢您的帮助:)
您正在使用HSQLDB进行单元测试并使用Oracle进行生产。 / b>
要使用Oracle方言运行HSQLDB,您必须首先在HSQLDB上启用Oracle语法兼容模式:
SET DATABASE SQL语法ORA TRUE;
运行时错误很可能是由对查询的结果大小施加的限制产生的。在Oracle中,这是通过使用伪列来实现的。 HSQLDB仅在兼容模式下理解ROWNUM。
I've got an issue with Hibernate when executing my unit tests, here is the issue I get :
org.springframework.dao.InvalidDataAccessResourceUsageException:
user lacks privilege or object not found: ROWNUM; SQL [n/a];
nested exception is org.hibernate.exception.SQLGrammarException:
user lacks privilege or object not found: ROWNUM
....
Caused by: org.hsqldb.HsqlException:
user lacks privilege or object not found: ROWNUM
I'm using :
<hibernate.version>4.1.0.Final</hibernate.version>
<hsqldb.version>2.3.3</hsqldb.version>
The function that I'm testing is perfectly working in the production environment, but I don't know why it's not the case when I'm testing it.
Here is the tested function that raise an error :
@Override
public EvaluationCriteria findByCriteriaIdAndEvaluationId(Long evaluationId, Long criteriaId) {
JPAQuery query = new JPAQuery(getEntityManager());
QEvaluationCriteria evaluationCriteria = QEvaluationCriteria.evaluationCriteria;
return query.from(evaluationCriteria)
.where(evaluationCriteria.evaluation.id.eq(evaluationId))
.where(evaluationCriteria.criteria.id.eq(criteriaId))
.singleResult(evaluationCriteria);
}
My test :
@Test
public void findByCriteriaIdAndEvaluationId() {
Long evaluationId = (long)1;
Long criteriaId = (long)1;
EvaluationCriteria result = null;
result = evaluationCriteriaDAO.findByCriteriaIdAndEvaluationId(evaluationId, criteriaId);
Assert.assertNotNull(result);
}
My Entity looks like this :
@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "SFINX_EVALUATION_CRITERIA", uniqueConstraints = @UniqueConstraint(columnNames = { "CRITERIA_ID", "EVALUATION_ID" }))
public class EvaluationCriteria implements Identifiable<Long> {
private static final long serialVersionUID = 6254229189011963873L;
private static final String SEQ_GENERATOR_NAME = "EvaluationCriteriaSeq";
private Long id;
private Criteria criteria;
private Evaluation evaluation;
@Override
@Id
@SequenceGenerator(name = SEQ_GENERATOR_NAME, initialValue = 1, sequenceName = "SFINX_EVALUATION_CRITERIA_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQ_GENERATOR_NAME)
@Column(name = "ID", updatable = false)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Criteria.class)
@JoinColumn(name = "CRITERIA_ID", nullable = false)
public Criteria getCriteria() {
return criteria;
}
public void setCriteria(Criteria criteria) {
this.criteria = criteria;
}
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Evaluation.class)
@JoinColumn(name = "EVALUATION_ID", nullable = false)
public Evaluation getEvaluation() {
return evaluation;
}
public void setEvaluation(Evaluation evaluation) {
this.evaluation = evaluation;
}
}
And my Persistence looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="testDaoUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.springframework.ldap.core.LdapTemplate</class>
<class>net.gdcw.sfinx.domain.Employee</class>
<class>net.gdcw.sfinx.domain.Criteria</class>
<class>net.gdcw.sfinx.domain.CriteriaType</class>
<class>net.gdcw.sfinx.domain.CriteriaTypeItem</class>
<class>net.gdcw.sfinx.domain.EmployeeEvaluation</class>
<class>net.gdcw.sfinx.domain.Evaluation</class>
<class>net.gdcw.sfinx.domain.EvaluationCriteria</class>
<class>net.gdcw.sfinx.domain.Feedback</class>
<class>net.gdcw.sfinx.domain.Project</class>
<class>net.gdcw.sfinx.domain.ProjectEmployee</class>
<class>net.gdcw.sfinx.domain.Role</class>
<class>net.gdcw.sfinx.domain.SystemRole</class>
<class>net.gdcw.sfinx.domain.ImprovementProposal</class>
<class>net.gdcw.sfinx.domain.Department</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="format_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="use_sql_comments" value="true"/>
<!-- cache properties -->
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="show_sql" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.cache.region.factory_class"
value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory" />
<property name="net.sf.ehcache.configurationResourceName" value="META-INF/ehcache.xml" />
</properties>
</persistence-unit>
</persistence>
And finally, the complete stack trace :
Hibernate: drop table SFINX_CRITERIA cascade constraints
Hibernate: drop table SFINX_CRITERIA_TYPE cascade constraints
Hibernate: drop table SFINX_CRITERIA_TYPE_ITEM cascade constraints
Hibernate: drop table SFINX_DEPARTMENT cascade constraints
Hibernate: drop table SFINX_EMPLOYEE cascade constraints
Hibernate: drop table SFINX_EMPLOYEE_EVALUATION cascade constraints
Hibernate: drop table SFINX_EMPLOYEE_SYSTEM_ROLE cascade constraints
Hibernate: drop table SFINX_EVALUATION cascade constraints
Hibernate: drop table SFINX_EVALUATION_CRITERIA cascade constraints
Hibernate: drop table SFINX_EVALUATION_MANAGER cascade constraints
Hibernate: drop table SFINX_EVALUATION_VIEWER cascade constraints
Hibernate: drop table SFINX_FEEDBACK cascade constraints
Hibernate: drop table SFINX_IMPROVEMENT_PROPOSAL cascade constraints
Hibernate: drop table SFINX_PROJECT cascade constraints
Hibernate: drop table SFINX_PROJECT_EMPLOYEE cascade constraints
Hibernate: drop table SFINX_ROLE cascade constraints
Hibernate: drop table SFINX_SYSTEM_ROLE cascade constraints
Hibernate: drop sequence SFINX_CRITERIA_SEQ
Hibernate: drop sequence SFINX_CRITERIA_TYPE_ITEM_SEQ
Hibernate: drop sequence SFINX_CRITERIA_TYPE_SEQ
Hibernate: drop sequence SFINX_DEPARTMENT_SEQ
Hibernate: drop sequence SFINX_EMPLOYEE_EVALUATION_SEQ
Hibernate: drop sequence SFINX_EMPLOYEE_SEQ
Hibernate: drop sequence SFINX_EVALUATION_CRITERIA_SEQ
Hibernate: drop sequence SFINX_EVALUATION_SEQ
Hibernate: drop sequence SFINX_FEEDBACK_SEQ
Hibernate: drop sequence SFINX_IMPROVEMENT_PROPOSAL_SEQ
Hibernate: drop sequence SFINX_PROJECT_EMPLOYEE_SEQ
Hibernate: drop sequence SFINX_PROJECT_SEQ
Hibernate: drop sequence SFINX_ROLE_SEQ
Hibernate: drop sequence SFINX_SYSTEM_ROLE_SEQ
Hibernate: create table SFINX_CRITERIA (ID number(19,0) not null, CREATE_DATE timestamp not null, UPDATE_DATE timestamp not null, DELETED char(1 char), DESCRIPTION varchar2(1000 char), NAME varchar2(255 char) not null, CRITERIA_TYPE_ID number(19,0) not null, primary key (ID), unique (NAME))
Hibernate: create table SFINX_CRITERIA_TYPE (ID number(19,0) not null, NAME varchar2(255 char) not null unique, primary key (ID), unique (NAME))
Hibernate: create table SFINX_CRITERIA_TYPE_ITEM (ID number(19,0) not null, VALUE varchar2(255 char) not null, CRITERIA_TYPE_ID number(19,0) not null, primary key (ID), unique (CRITERIA_TYPE_ID, VALUE))
Hibernate: create table SFINX_DEPARTMENT (ID number(19,0) not null, NAME varchar2(255 char) not null, primary key (ID), unique (NAME))
Hibernate: create table SFINX_EMPLOYEE (ID number(19,0) not null, ARCHIVED char(1 char), EMAIL varchar2(255 char), FIRST_NAME varchar2(255 char), LAST_NAME varchar2(255 char), LOGIN varchar2(255 char) not null unique, DEPARTMENT_ID number(19,0), primary key (ID), unique (LOGIN))
Hibernate: create table SFINX_EMPLOYEE_EVALUATION (ID number(19,0) not null, CREATE_DATE timestamp not null, UPDATE_DATE timestamp not null, EMPLOYEE_ID number(19,0) not null, EVALUATION_ID number(19,0) not null, PROJECT_ID number(19,0) not null, primary key (ID), unique (EVALUATION_ID, EMPLOYEE_ID, PROJECT_ID))
Hibernate: create table SFINX_EMPLOYEE_SYSTEM_ROLE (EMPLOYEE_ID number(19,0) not null, SYSTEM_ROLE_ID number(19,0) not null)
Hibernate: create table SFINX_EVALUATION (ID number(19,0) not null, CREATE_DATE timestamp not null, UPDATE_DATE timestamp not null, CLOSURE_DATE timestamp, DELETED char(1 char), DESCRIPTION varchar2(1000 char), END_DATE timestamp, NAME varchar2(255 char) not null, START_DATE timestamp, STATUS varchar2(255 char), MASTER_ID number(19,0) not null, primary key (ID), unique (NAME))
Hibernate: create table SFINX_EVALUATION_CRITERIA (ID number(19,0) not null, CRITERIA_ID number(19,0) not null, EVALUATION_ID number(19,0) not null, primary key (ID), unique (CRITERIA_ID, EVALUATION_ID))
Hibernate: create table SFINX_EVALUATION_MANAGER (EVALUATION_ID number(19,0) not null, MANAGER_ID number(19,0) not null)
Hibernate: create table SFINX_EVALUATION_VIEWER (EVALUATION_ID number(19,0) not null, VIEWER_ID number(19,0) not null)
Hibernate: create table SFINX_FEEDBACK (ID number(19,0) not null, CREATE_DATE timestamp not null, UPDATE_DATE timestamp not null, COMMENTS varchar2(1000 char), RELEASED char(1 char), VALUE varchar2(255 char), EMPLOYEE_EVALUATION_ID number(19,0) not null, EMPLOYEE_ID number(19,0) not null, EVALUATION_CRITERIA_ID number(19,0) not null, primary key (ID), unique (EMPLOYEE_ID, EMPLOYEE_EVALUATION_ID, EVALUATION_CRITERIA_ID))
Hibernate: create table SFINX_IMPROVEMENT_PROPOSAL (ID number(19,0) not null, PROPOSAL varchar2(1000 char) not null, EMPLOYEE_ID number(19,0) not null, primary key (ID))
Hibernate: create table SFINX_PROJECT (ID number(19,0) not null, CLIENT_NAME varchar2(255 char), DELETED char(1 char), END_DATE timestamp not null, NAME varchar2(255 char) not null, START_DATE timestamp not null, WBS varchar2(255 char), primary key (ID), unique (NAME))
Hibernate: create table SFINX_PROJECT_EMPLOYEE (ID number(19,0) not null, EMPLOYEE_ID number(19,0) not null, PROJECT_ID number(19,0), ROLE_ID number(19,0) not null, primary key (ID), unique (EMPLOYEE_ID, PROJECT_ID))
Hibernate: create table SFINX_ROLE (ID number(19,0) not null, DELETED char(1 char), NAME varchar2(255 char), primary key (ID), unique (NAME))
Hibernate: create table SFINX_SYSTEM_ROLE (ID number(19,0) not null, DELETED char(1 char), NAME varchar2(255 char) not null, primary key (ID), unique (NAME))
Hibernate: alter table SFINX_CRITERIA add constraint FKA3B6A81EED06FF7E foreign key (CRITERIA_TYPE_ID) references SFINX_CRITERIA_TYPE
Hibernate: alter table SFINX_CRITERIA_TYPE_ITEM add constraint FKEE5DAE17ED06FF7E foreign key (CRITERIA_TYPE_ID) references SFINX_CRITERIA_TYPE
Hibernate: alter table SFINX_EMPLOYEE add constraint FK767FAF6D15CF1A9F foreign key (DEPARTMENT_ID) references SFINX_DEPARTMENT
Hibernate: alter table SFINX_EMPLOYEE_EVALUATION add constraint FK1BC4A34ECDBE9A5F foreign key (EVALUATION_ID) references SFINX_EVALUATION
Hibernate: alter table SFINX_EMPLOYEE_EVALUATION add constraint FK1BC4A34EE55C6715 foreign key (PROJECT_ID) references SFINX_PROJECT
Hibernate: alter table SFINX_EMPLOYEE_EVALUATION add constraint FK1BC4A34EB756525F foreign key (EMPLOYEE_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_EMPLOYEE_SYSTEM_ROLE add constraint FKD0BCA2B4500008DE foreign key (SYSTEM_ROLE_ID) references SFINX_SYSTEM_ROLE
Hibernate: alter table SFINX_EMPLOYEE_SYSTEM_ROLE add constraint FKD0BCA2B4B756525F foreign key (EMPLOYEE_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_EVALUATION add constraint FKFE79983B8D73022B foreign key (MASTER_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_EVALUATION_CRITERIA add constraint FKCA237AE3CDBE9A5F foreign key (EVALUATION_ID) references SFINX_EVALUATION
Hibernate: alter table SFINX_EVALUATION_CRITERIA add constraint FKCA237AE394A3C8BF foreign key (CRITERIA_ID) references SFINX_CRITERIA
Hibernate: alter table SFINX_EVALUATION_MANAGER add constraint FK2C4B6F89CDBE9A5F foreign key (EVALUATION_ID) references SFINX_EVALUATION
Hibernate: alter table SFINX_EVALUATION_MANAGER add constraint FK2C4B6F8915931500 foreign key (MANAGER_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_EVALUATION_VIEWER add constraint FK5346E296CDBE9A5F foreign key (EVALUATION_ID) references SFINX_EVALUATION
Hibernate: alter table SFINX_EVALUATION_VIEWER add constraint FK5346E296236B9C7B foreign key (VIEWER_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_FEEDBACK add constraint FK23F2B44486766958 foreign key (EVALUATION_CRITERIA_ID) references SFINX_EVALUATION_CRITERIA
Hibernate: alter table SFINX_FEEDBACK add constraint FK23F2B444B756525F foreign key (EMPLOYEE_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_FEEDBACK add constraint FK23F2B444CE47D6DC foreign key (EMPLOYEE_EVALUATION_ID) references SFINX_EMPLOYEE_EVALUATION
Hibernate: alter table SFINX_IMPROVEMENT_PROPOSAL add constraint FK49CA2A9AB756525F foreign key (EMPLOYEE_ID) references SFINX_EMPLOYEE
Hibernate: alter table SFINX_PROJECT_EMPLOYEE add constraint FKE09FA2F3E55C6715 foreign key (PROJECT_ID) references SFINX_PROJECT
Hibernate: alter table SFINX_PROJECT_EMPLOYEE add constraint FKE09FA2F3BBCC17DF foreign key (ROLE_ID) references SFINX_ROLE
Hibernate: alter table SFINX_PROJECT_EMPLOYEE add constraint FKE09FA2F3B756525F foreign key (EMPLOYEE_ID) references SFINX_EMPLOYEE
Hibernate: create sequence SFINX_CRITERIA_SEQ
Hibernate: create sequence SFINX_CRITERIA_TYPE_ITEM_SEQ
Hibernate: create sequence SFINX_CRITERIA_TYPE_SEQ
Hibernate: create sequence SFINX_DEPARTMENT_SEQ
Hibernate: create sequence SFINX_EMPLOYEE_EVALUATION_SEQ
Hibernate: create sequence SFINX_EMPLOYEE_SEQ
Hibernate: create sequence SFINX_EVALUATION_CRITERIA_SEQ
Hibernate: create sequence SFINX_EVALUATION_SEQ
Hibernate: create sequence SFINX_FEEDBACK_SEQ
Hibernate: create sequence SFINX_IMPROVEMENT_PROPOSAL_SEQ
Hibernate: create sequence SFINX_PROJECT_EMPLOYEE_SEQ
Hibernate: create sequence SFINX_PROJECT_SEQ
Hibernate: create sequence SFINX_ROLE_SEQ
Hibernate: create sequence SFINX_SYSTEM_ROLE_SEQ
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.056 sec <<< FAILURE!
findByCriteriaIdAndEvaluationId(net.gdcw.sfinx.dao.EvaluationCriteriaDaoTest) Time elapsed: 0.026 sec <<< ERROR!
org.springframework.dao.InvalidDataAccessResourceUsageException: user lacks privilege or object not found: ROWNUM; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: user lacks privilege or object not found: ROWNUM
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:231)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:214)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy47.findByCriteriaIdAndEvaluationId(Unknown Source)
at net.gdcw.sfinx.dao.EvaluationCriteriaDaoTest.findByCriteriaIdAndEvaluationId(EvaluationCriteriaDaoTest.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:72)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:81)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:216)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:82)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:67)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:162)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.hibernate.exception.SQLGrammarException: user lacks privilege or object not found: ROWNUM
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:83)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:146)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy57.prepareStatement(Unknown Source)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1720)
at org.hibernate.loader.Loader.doQuery(Loader.java:828)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2447)
at org.hibernate.loader.Loader.doList(Loader.java:2433)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2263)
at org.hibernate.loader.Loader.list(Loader.java:2258)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1161)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:280)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:360)
at com.sun.proxy.$Proxy56.getSingleResult(Unknown Source)
at com.mysema.query.jpa.impl.AbstractJPAQuery.getSingleResult(AbstractJPAQuery.java:245)
at com.mysema.query.jpa.impl.AbstractJPAQuery.uniqueResult(AbstractJPAQuery.java:323)
at com.mysema.query.jpa.impl.AbstractJPAQuery.uniqueResult(AbstractJPAQuery.java:308)
at com.mysema.query.support.ProjectableQuery.singleResult(ProjectableQuery.java:150)
at net.gdcw.sfinx.dao.EvaluationCriteriaDAOImpl.findByCriteriaIdAndEvaluationId(EvaluationCriteriaDAOImpl.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 39 more
Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ROWNUM
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
... 76 more
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ROWNUM
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)
at org.hsqldb.QueryExpression.resolve(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 83 more
My main concerns about this problem is :
- It's perfectly working in Production
- There is absolutely nothing like
ROWNUM
in all my code.
So I basically don't understand what Hibernate wants to tell me ^^.Thanks in advance for your help :)
You are using HSQLDB for unit tests and Oracle in production.
To run HSQLDB with the Oracle dialect you must first enable Oracle syntax compatibility mode on HSQLDB:
SET DATABASE SQL SYNTAX ORA TRUE;
The runtime error was most likely produced by a limit imposed on the result size of query. In Oracle this is implemented by using the pseudocolumn ROWNUM. HSQLDB understands ROWNUM only in compatibility mode.
这篇关于单元测试引发:HsqlException用户缺少权限或找不到对象:ROWNUM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!