web-dev-qa-db-ja.com

ユニットテストが発生します:HsqlExceptionユーザーに特権がないか、オブジェクトが見つかりません:ROWNUM

ユニットテストの実行時にHibernateに問題が発生しました。これが、発生する問題です。

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

私が使用している:

<hibernate.version>4.1.0.Final</hibernate.version>

<hsqldb.version>2.3.3</hsqldb.version>

私がテストしている関数は本番環境で完全に機能していますが、テストしているときになぜそうではないのかわかりません。

エラーを発生させるテスト済みの関数は次のとおりです。

@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);
}

私のテスト:

@Test
public void findByCriteriaIdAndEvaluationId() {

    Long evaluationId = (long)1;
    Long criteriaId   = (long)1;

    EvaluationCriteria result = 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";

    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;
    }
}

そして私の永続性は次のようになります:

<?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>

そして最後に、完全なスタックトレース:

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

この問題に関する私の主な懸念は次のとおりです。

  • 本番環境で完全に機能しています
  • 私のすべてのコードには、ROWNUMのようなものはまったくありません。

だから私は基本的にHibernateが私に何を伝えたいのか理解していません^^。よろしくお願いします:)

7

単体テストにはHSQLDBを使用し、本番環境ではOracleを使用しています。

OracleダイアレクトでHSQLDBを実行するには、最初にHSQLDBでOracle構文互換モードを有効にする必要があります。

SET DATABASE SQL SYNTAX ORA TRUE;

ランタイムエラーは、クエリの結果サイズに課せられた制限によって発生した可能性があります。 Oracleでは、これは疑似列 [〜#〜] rownum [〜#〜] を使用して実装されます。 HSQLDBは​​、互換モードでのみROWNUMを理解します。

20
wero