-->
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: ERROR: relation "hibernate_sequence" does not exis
PostPosted: Tue Dec 30, 2003 10:55 am 
Newbie

Joined: Tue Dec 30, 2003 10:46 am
Posts: 4
Hello all,

I am studing Hibernate to use it with a new project (DB is Postgresql 7.4

), but got the following problem:

net.sf.hibernate.JDBCException: Could not save object
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:744)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at ConexaoHibernate.inserirEntidade(ConexaoHibernate.java:36)
at Principal.main(Principal.java:29)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist

at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:231)
at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:69)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:727)
... 3 more

During the logging process everything seems to be fine until:

14080 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
14090 [main] DEBUG net.sf.hibernate.SQL - select nextval ('hibernate_sequence')
Hibernate: select nextval ('hibernate_sequence')
14090 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
15021 [main] DEBUG net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist

at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:231)
at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:69)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:727)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at ConexaoHibernate.inserirEntidade(ConexaoHibernate.java:36)
at Principal.main(Principal.java:29)
15082 [main] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42P01
15092 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - ERROR: relation "hibernate_sequence" does not exist

15092 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
15092 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
15152 [main] DEBUG net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist


Can anyone help me out ??

Happy new year for everyone,

Luiz


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 11:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hibernate is trying to get the next identity value by executing select nextval ('hibernate_sequence'). I would suspect there is no sequence called hibernate_sequence in your db, and you need to define one. Don't know how this works using Postgre however


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 5:32 pm 
Newbie

Joined: Tue Dec 30, 2003 10:46 am
Posts: 4
Thank you,

Already figured it out. It works using the generator as following:

<generator class="increment"/>

and

unsaved-value="-1"

as in

<id name="idCliente" column="ID_CLIENTE" type="long" unsaved-value="-1">

The Hibernate did all the rest.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 5:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Note however that using increment generator is not particulary save. You should probably try to get sequence to work, this is definately better, and should really just involve adding a sequence to your database (Postger users, speak up how to do this ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2003 7:14 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gloeglm wrote:
Note however that using increment generator is not particulary safe.

It's safe in a non multithreaded, non clustered environnement.

_________________
Emmanuel


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.