hibernate中的序列不存在错误

时间:2016-10-24 08:53:20

标签: oracle hibernate java-ee

我正在使用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>

但是当我试图将实体持久化到db

时,我收到此错误
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
.
.
.
.
Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist

请建议我一个解决方案

1 个答案:

答案 0 :(得分:1)

请你试着写一下

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