【问题标题】:sequence does not exist error in hibernate休眠中的序列不存在错误
【发布时间】:2017-03-05 23:41:06
【问题描述】:

我正在使用 JSF 和 hibernate 开发一个 java 应用程序,数据库是 oracle。

这是我的实体类------

@Entity
@Table(name="docUpload")
@SequenceGenerator(name="seqGen",sequenceName="docseq")
public class DocDetailsEntity {

@Id
@GeneratedValue(generator="seqGen",strategy=GenerationType.SEQUENCE)
private Integer docId;
private String docName;
private String docDesc;
private String userId;
@Lob
private Clob doc;

表格脚本--------

create table docUpload
(
docId number(10) primary key,
docName varchar2(50) not null,
docDesc varchar2(100),
userId varchar2(10) not null,
doc clob not null
);
CREATE SEQUENCE docseq
START WITH     100
INCREMENT BY   1
NOCACHE
NOCYCLE;

hibernate.cfg.xml-----

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC 
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- hibernate dialect -->
<property  name="hibernate.dialect">  org.hibernate.dialect.OracleDialect   </property> 
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@xxxxx:1521:xx</property>
    <property name="hibernate.connection.username">xxxx</property>
    <property name="hibernate.connection.password">xxxx</property>
    <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

    <!-- Automatic schema creation (begin) === -->
    <property name="hibernate.hbm2ddl.auto">none</property>

    <!-- Simple memory-only cache -->
    <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>

    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>

    <!-- <property name="show_sql">true</property> -->
    <mapping class="entity.DocDetailsEntity"/>
    </session-factory>
    </hibernate-configuration>

但是当我尝试将实体持久保存到数据库时出现此错误

org.hibernate.exception.SQLGrammarException: could not extract ResultSet
.
.
.
.
Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist

请给我一个解决方案

【问题讨论】:

  • 可能是案例问题? Oracle中的序列是大写的('DOCSEQ')
  • 您是否更正了 GRANT 权限?
  • 特权?其他模式中的对象?告诉我们更多关于连接到数据库的用户和存储表和序列的模式
  • 不,这个案子没有问题..它是正确的
  • 目前没有用户访问数据库..只有我试图坚持

标签: oracle hibernate jakarta-ee


【解决方案1】:

你能不能试着写成

@Table(name="docUpload",schema = "schemaName" )
@SequenceGenerator(name="seqGen",sequenceName="schemaName.seqName")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 2018-01-28
    • 2011-05-28
    • 1970-01-01
    • 2017-12-23
    相关资源
    最近更新 更多