-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Problem saving the object in oracle 10g through hibernate
PostPosted: Sun Jul 31, 2011 2:20 am 
Newbie

Joined: Sun Jul 31, 2011 2:08 am
Posts: 2
Hello friends,

I am using the Oracle 10g express edition as backend database. I am trying to run a basic program which takes a Pojo class and persist to Oracle database using Session.save(object). I am getting the below mentioned error. Please help. (note: I am using the username and password within the connection url as I am not using thin client).

Connection properties in Hibernate.cfg.xml
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">hr</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:hr/hr@localhost:1521/XE</property>
<property name="hibernate.connection.username">hr</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>


Error message.

org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:132)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:105)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:713)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:701)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:697)
at com.vaannila.course.Main.saveCourse(Main.java:33)
at com.vaannila.course.Main.main(Main.java:15)
Caused by: java.sql.SQLException: ORA-02289: sequence does not exist


and so on..Actually the complete error message is quite long.


Top
 Profile  
 
 Post subject: Re: Problem saving the object in oracle 10g through hibernate
PostPosted: Sun Jul 31, 2011 1:57 pm 
Newbie

Joined: Sat Mar 26, 2011 8:57 am
Posts: 6
what kind of primary-key generation are you using?


Top
 Profile  
 
 Post subject: Re: Problem saving the object in oracle 10g through hibernate
PostPosted: Sun Jul 31, 2011 4:14 pm 
Newbie

Joined: Sun Jul 31, 2011 2:08 am
Posts: 2
Generator class is native.


Top
 Profile  
 
 Post subject: Re: Problem saving the object in oracle 10g through hibernate
PostPosted: Sun Jul 31, 2011 4:18 pm 
Newbie

Joined: Sat Mar 26, 2011 8:57 am
Posts: 6
org.hibernate.exception.SQLGrammarException: could not get next sequence value - looks like you have problems generating a prim. key. Try to set the generationtype to auto.


Top
 Profile  
 
 Post subject: Re: Problem saving the object in oracle 10g through hibernate
PostPosted: Mon Aug 01, 2011 2:06 am 
Newbie

Joined: Tue Jul 26, 2011 1:30 am
Posts: 5
Hi,
create a sequence first and write this code in your hbm file
<id column="ID" name="id" type="integer">
<generator class="sequence">
<param name="sequence"> YOUR_SEQUENCE_NAME </param>
</generator>
</id>
i think problem will solve by this.

Ramesh K,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.