-->
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.  [ 2 posts ] 
Author Message
 Post subject: Increment generator for IDs not working with a schema
PostPosted: Thu Jul 27, 2006 6:54 am 
Newbie

Joined: Thu Jul 27, 2006 5:48 am
Posts: 1
I'm having a problem with the Increment generator for ids. The SQL it is using to select the maximum id from a table is not including the schema name of the table (core - see the SQL at the bottom of this post). Am I missing something from the id element in the mapping file?

Hibernate version:
3.1

Mapping documents:

Excerpt from Sequence.hbm.xml

Code:
    <class name="Sequence" table="sequence" schema="core">
        <id name="sequenceId" type="int">
            <column name="sequence_id" />
            <generator class="increment" />
        </id>


Code between sessionFactory.openSession() and session.close():

Code:
Sequence foo = new Sequence();
foo.setString("Abcd");
session.store(foo);


And some other standard transaction stuff around that...

Full stack trace of any exception that occurs:
Code:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:107)
   at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:44)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
   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:530)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
   at dataaccess.EntityManager.Store(EntityManager.java:112)
   at dataaccess.test.HibernateTester.testDatabaseStore(HibernateTester.java:60)
   at dataaccess.test.HibernateTester.main(HibernateTester.java:44)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "sequence" does not exist
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:437)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:257)
   at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:85)
   ... 13 more


Name and version of the database you are using:

PostgreSQL 8.1

The generated SQL (show_sql=true):

Code:
    select
        max(sequence_id)
    from
        sequence


The SQL really should be

Code:
    select
        max(sequence_id)
    from
        core.sequence


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:33 pm 
Newbie

Joined: Wed Jan 31, 2007 7:27 pm
Posts: 3
I too am getting this issue.

It appears a bub for it has been opened.
http://opensource.atlassian.com/project ... 6?page=all


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