-->
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.  [ 3 posts ] 
Author Message
 Post subject: could not get next sequence
PostPosted: Sun Nov 12, 2006 6:22 am 
Newbie

Joined: Tue Oct 31, 2006 5:19 am
Posts: 11
Hi all,
i am getting this error. but i don't know where did i do wrong, could anybody help?

Caused by: org.hibernate.exception.GenericJDBCException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at src.ejb.HibernateBean.createPerson(HibernateBean.java:163)
my sequence in mapping file:
<class name="src.hibernate.Person" table="TMP_PERSON">
<id name="id" column="PERSONID">
<generator class="sequence"/>
my java class:
public class Person {
private Long id;
getter and setter;
.....
}

method :
public Long createPerson(
String surname,
String firstname,
String tel,
String email) {
Session session = null;
Transaction tx = null;

try {
session = HibernateSessionFactory.openSession();
tx = session.beginTransaction();
Person aPerson = new Person();
aPerson.setSurname(surname);
aPerson.setFirstname(firstname);
aPerson.setTelNr(tel);
aPerson.setEmail(email);
Long personId = (Long)session.save(aPerson);
tx.commit();
return personId;
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw new HibernateException(e);
} finally {
HibernateSessionFactory.closeSession(session);
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 11:04 am 
Newbie

Joined: Thu Nov 09, 2006 4:37 am
Posts: 7
Location: Beijing China
First of all, I'm using Oracle sequence. With the following configuration you should get to the right place.

Create sequence in Oracle:

Code:
create sequence seq_id
minvalue 1
start with 1
increment by 1
cache 20;


then config id property in hbm.xml file:

Code:
<id column="ID" name="id" type="integer">
         <generator class="sequence">
              <param name="sequence">seq_id</param>
         </generator>
</id>


make sure the type of id property in your java file is long, short or integer ;)

_________________
Make it work ;)


Top
 Profile  
 
 Post subject: Re: could not get next sequence
PostPosted: Tue Dec 22, 2009 1:15 am 
Newbie

Joined: Mon Dec 21, 2009 3:10 pm
Posts: 1
I had the same problem with postgres. Check whether the log in role of your DB and the password is true
in your hibernate config file.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.