Reputation: 75
I am working on a java application using JSF and hibernate and the database is oracle.
this is my entity class---------
@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;
table scrips--------
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>
but i am getting this error when i am trying to persist the entity into the db
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
.
.
.
.
Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist
please suggest me a solution
Upvotes: 1
Views: 2862
Reputation: 1457
Could you please try to write as
@Table(name="docUpload",schema = "schemaName" )
@SequenceGenerator(name="seqGen",sequenceName="schemaName.seqName")
Upvotes: 1