java.sql.SQLSyntaxErrorException:ORA-02289:序列不存在

java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist

提问人:StormBreaker 提问时间:7/29/2022 最后编辑:StormBreaker 更新时间:7/29/2022 访问量:1126

问:

在此方法中,我收到错误 java.sql.SQLSyntaxErrorException:ORA-02289:序列不存在我已经浏览了帖子,但我没有得到任何修复它的想法

public void saveOrUpdateProcessRun(ProcessRun argProcessRun) {
LOGGER.info(METHOD_START);
getHibernateTemplate().saveOrUpdate(argProcessRun);
LOGGER.info(METHOD_END);
}

这是映射我有基于 XML 的配置生成器类不工作(PROC_RUN_ID_SEQ)

    <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.uhg.esbdb.common.beans">

    <class name="ProcessRun" table="PROC_RUN">
        <id name="processRunID" type="integer" column="PROC_RUN_ID">
            <generator class="sequence">
                <param name="sequence">PROC_RUN_ID_SEQ</param>
            </generator>
        </id>

        <property name="processID" type="integer" column="PROC_ID" />
        <property name="processRunStartDatetime" type="timestamp"
            column="PROC_RUN_STRT_DTTM" />
        <property name="processRunEndDatetime" type="timestamp"
            column="PROC_RUN_END_DTTM" />
        <property name="processRunStatusCode" type="integer" column="PROC_RUN_STS_CD" />
        <property name="createdByID" type="string" column="CRE_BY_ID" />
        <property name="createdDatetime" type="timestamp" column="CRE_DTTM" />
        <property name="modifiedByID" type="string" column="MOD_BY_ID" />
        <property name="modifiedDatetime" type="timestamp" column="MOD_DTTM" />
    </class>

    <class name="FileLoad" table="FL_LOAD">
        <id name="fileLoadID" type="integer" column="FL_LOAD_ID">
            <generator class="sequence">
                <param name="sequence">FL_LOAD_ID_SEQ</param>
            </generator>
        </id>
        <property name="dataFileName" type="string" column="DATA_FL_NM" />
        <property name="dataFileSizeByteNumber" type="integer"
            column="DATA_FL_SZ_BYTE_NBR" />
        <property name="fileLoadStatusCode" type="integer" column="FL_LOAD_STS_CD" />
        <property name="loadStartDatetime" type="timestamp" column="LOAD_STRT_DTM" />
        <property name="loadEndDatetime" type="timestamp" column="LOAD_END_DTM" />
        <property name="createdByID" type="string" column="CRE_BY_ID" />
        <property name="createdDatetime" type="timestamp" column="CRE_DTTM" />
        <property name="modifiedByID" type="string" column="MOD_BY_ID" />
        <property name="modifiedDatetime" type="timestamp" column="MOD_DTTM" />
        <many-to-one name="processRun" class="ProcessRun" column="PROC_RUN_ID" />
    </class>

    <class name="ControlTotal" table="CTL_TOT">
        <composite-id name="id" class="ControlTotalID">
            <key-many-to-one name="fileLoad" class="FileLoad"
                column="FL_LOAD_ID" />
            <key-property name="controlTotalTypeCode" type="integer"
                column="CTL_TOT_TYP_CD" />
        </composite-id>
        <property name="controlTotal" type="string" column="CTL_TOT" />
        <property name="createdByID" type="string" column="CRE_BY_ID" />
        <property name="createdDatetime" type="timestamp" column="CRE_DTTM" />
        <property name="modifiedByID" type="string" column="MOD_BY_ID" />
        <property name="modifiedDatetime" type="timestamp" column="MOD_DTTM" />
    </class>
    <!-- Added for loading wfg transaction ids from BE017 and BNKACH feeds to the EDB table  EDBREF.WFG_ACH_PAYMENTS-->
    <class name="WfgTransactionIdBean" table="EDBREF.WFG_ACH_PAYMENTS">
        <id name="traceNumber" type="string" column="TRACE_NUMBER"></id>
        <property name="sourceSystem" type="string" column="SOURCE_SYSTEM" />
        <property name="transactionDate" type="timestamp" column="TRANSACTION_DATE" />
        <property name="processed" type="string" column="PROCESSED" />
    </class>
</hibernate-mapping>

而不是PROC_RUN_ID_SEQ我得到 >DEBUG main SQL logStatement:92 - select hibernate_sequence.nextval from dual

Oracle 休眠 序列

评论

0赞 Jens 7/29/2022
此错误消息不清楚什么?

答:

1赞 Joe Taras 7/29/2022 #1

原因可能不同:

  1. 您在 pojo 中映射的序列的名称不同
  2. 您无权使用序列
  3. 您没有在数据库上定义序列

解决 方案

  1. 修复 pojo 上的序列名称
  2. 为数据库用户授予序列
  3. 在数据库上添加序列

更新问题后编辑

请尝试以下操作:

<id name="propName" type="long" unsaved-value="null">
        <column name="columnName" not-null="true" unique="true"
            index="pkName" />
        <generator
            class="org.hibernate.id.enhanced.SequenceStyleGenerator">
            <param name="optimizer">none</param>
            <param name="increment_size">1</param>
            <param name="sequence_name">PROC_RUN_ID_SEQ</param>
        </generator>
</id>

评论

0赞 StormBreaker 7/29/2022
我已经更新了问题,请你看看
0赞 Joe Taras 7/29/2022
@StormBreaker检查我更新的答案