I've recently switched from an increment generator to a seqhilo using postgresql sequences. One session in hibernate and only hibernate is creating objects with the ids generated. It seems as though when hibernate reaches the increment value (10000) and fetches the next sequence value it throws a jdbc exception and I'm not quite sure what the problem is. Any suggestions would be appreciated, could not find anything on the web or forums. Perhaps the problem could be the sequence cache? I never received these before with the increment generator, so I didn't think it was the connection handling.
Hibernate version:
3.2 cr4
Mapping documents:
Code:
...
<class name="Record" abstract="true" batch-size="16">
<cache usage="read-write" />
<id name="id" type="long" column="REC_ID" unsaved-value="null">
<generator class="seqhilo">
<param name="sequence">rec_id_seq</param>
<param name="max_lo">10000</param>
</generator>
</id>
...
hibernate.cfg.xml
...
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/isis?autoReconnect=true</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.connection.autoReconnect">true</property>
<property name="hibernate.connection.autoReconnectForPools">true</property>
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">UTF-8</property>
<property name="hibernate.jdbc.fetch_size">32</property>
<property name="hibernate.jdbc.batch_size">32</property>
<!-- Hibernate Configuration Properties -->
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.order_updates">false</property>
<property name="hibernate.generate_statistics">false</property>
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">300</property>
<property name="c3p0.min_size">3</property>
<property name="c3p0.max_size">8</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.timeout">30</property>
<property name="c3p0.num_helper_threads">5</property>
<property name="c3p0.testConnectionOnCheckin">false</property>
<property name="c3p0.testConnectionOnCheckout">true</property>
<!-- Hibernate Cache Properties -->
<!-- See http://ehcache.sourceforge.net/documentation/#mozTocId116611 for details -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.use_unstructured_entries">true</property>
...
c3p0.properties
c3p0.acquireRetryDelay=5000
c3p0.acquireRetryAttempts=-1
c3p0.breakAfterAcquireFailure=true
...
Full stack trace of any exception that occurs:Code:
2006-09-30 13:40:10,425 [UPDATE DB] WARN NewPooledConnection:356 - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
2006-09-30 13:40:10,425 [UPDATE DB] WARN NewPooledConnection:357 - [c3p0] Another error has occurred [ org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored un
til end of transaction block ] which will not be reported to listeners!
org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:258)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
at org.hibernate.id.SequenceHiLoGenerator.generate(SequenceHiLoGenerator.java:58)
at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:81)
at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:75)
at us.sotech.recorderbase.services.dbmanager.EventPersistenceManager.saveOrUpdateRecordEvent(EventPersistenceManager.java:129)
at us.sotech.recorderbase.services.dbmanager.EventPersistenceManager$1.process(EventPersistenceManager.java:56)
at us.sotech.recorderbase.services.dbmanager.EventPersistenceManager$1.process(EventPersistenceManager.java:1)
at us.sotech.recorderbase.events.QueueProcessingThread.executeTask(QueueProcessingThread.java:31)
at us.sotech.util.StoppableThread.run(StoppableThread.java:96)
2006-09-30 13:40:10,425 [UPDATE DB] WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 25P02
2006-09-30 13:40:10,425 [UPDATE DB] ERROR JDBCExceptionReporter:72 - ERROR: current transaction is aborted, commands ignored until end of transaction block
2006-09-30 13:40:10,426 [UPDATE DB] ERROR EventPersistenceManager:157 - opening new session
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.id.SequenceHiLoGenerator.generate(SequenceHiLoGenerator.java:58)
at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:81)
at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:75)
at us.sotech.recorderbase.services.dbmanager.EventPersistenceManager.saveOrUpdateRecordEvent(EventPersistenceManager.java:129)
at us.sotech.recorderbase.services.dbmanager.EventPersistenceManager$1.process(EventPersistenceManager.java:56)
at us.sotech.recorderbase.services.dbmanager.EventPersistenceManager$1.process(EventPersistenceManager.java:1)
at us.sotech.recorderbase.events.QueueProcessingThread.executeTask(QueueProcessingThread.java:31)
at us.sotech.util.StoppableThread.run(StoppableThread.java:96)
Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:258)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
... 8 more
Name and version of the database you are using:PostgreSQL 8.1.4 Gentoo
Sequence Definition:Code:
select * from rec_id_seq;
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
rec_id_seq | 601649999 | 10000 | 9223372036854775807 | 1 | 10 | 32 | f | t
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html