The object is already closed - after switching Hibernate from version 4.2.7 to 4.3.1

755 views
Skip to first unread message

Axel Röber

unread,
Feb 9, 2014, 2:38:24 AM2/9/14
to h2-da...@googlegroups.com
Hi,

a few days ago I switched the Hibernate version from 4.2.7 (JPA2) to 4.3.1 (JPA2.1) on an existing (spring) application.
Everthing seems to work fine but I was wondering why the application slows down. Then I detected a very big H2 trace file (.trace.db) only containing 'The object is already closed' org.h2.jdbc.JdbcSQLExceptions.
It seems that nearly every Update and Insert statement throws this exception.
Going back to Hibernate 4.2 and the exceptions are thrown no longer.
This can be seen by using H2 Version 1.3.175 and Version 1.3.174 (in embedded mode).

Any ideas on this? How can I change the Hibernate, Spring and/or H2 configuration to avoid this?

Best regards
Axel

org.h2.jdbc.JdbcSQLException: Das Objekt wurde bereits geschlossen
The object is already closed [90007-174]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
    at org.h2.message.DbException.get(DbException.java:172)
    at org.h2.message.DbException.get(DbException.java:149)
    at org.h2.message.DbException.get(DbException.java:138)
    at org.h2.jdbc.JdbcStatement.checkClosed(JdbcStatement.java:978)
    at org.h2.jdbc.JdbcPreparedStatement.checkClosed(JdbcPreparedStatement.java:1574)
    at org.h2.jdbc.JdbcStatement.checkClosed(JdbcStatement.java:954)
    at org.h2.jdbc.JdbcStatement.getMaxRows(JdbcStatement.java:356)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:530)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.release(JdbcCoordinatorImpl.java:407)
    at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.releaseStatements(AbstractBatchImpl.java:173)
    at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:76)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3281)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3183)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3525)
    at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:158)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:453)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:345)
    at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1218)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:366)
    at com.sun.proxy.$Proxy51.flush(Unknown Source)
    ...

Noel Grandin

unread,
Feb 10, 2014, 2:43:00 AM2/10/14
to h2-da...@googlegroups.com


On 2014-02-09 09:38, Axel Röber wrote:
> Hi,
>
> a few days ago I switched the Hibernate version from 4.2.7 (JPA2) to 4.3.1 (JPA2.1) on an existing (spring) application.
> Everthing seems to work fine but I was wondering why the application slows down. Then I detected a very big H2 trace
> file (.trace.db) only containing 'The object is already closed' org.h2.jdbc.JdbcSQLExceptions.
> It seems that nearly every Update and Insert statement throws this exception.
> Going back to Hibernate 4.2 and the exceptions are thrown no longer.
> This can be seen by using H2 Version 1.3.175 and Version 1.3.174 (in embedded mode).
>
> Any ideas on this? How can I change the Hibernate, Spring and/or H2 configuration to avoid this?
>

That looks like a bug in Hibernate - it should not be calling that method on a closed Statement object.
I suggest you bring it up on the Hibernate mailing list.

Axel Röber

unread,
Feb 10, 2014, 3:59:35 AM2/10/14
to h2-da...@googlegroups.com
I partly agree that this is a bug in hibernate. But Derby and HSQLDB are working also fine (as H2) in this scenario - with the exception that they do not log exceptions.
I guess they only don't check the closure state of the object. But as the application itself works fine, it seems that the H2 exceptions in the trace file are a kind of warning. And I am looking for a way to disabe this.
And it is interesting whether someone else has made some experience with H2 and Hibernate 4.3(.1).

Thomas Mueller

unread,
Feb 10, 2014, 12:20:57 PM2/10/14
to H2 Google Group
Hi,

> with the exception that they do not log exceptions

Yes. Creating exceptions is very slow in Java (filling the stack trace is the slow part). Of course, logging exceptions is probably even slower, but if possible both should be avoided. For H2, logging exceptions can be disabled by appending ";TRACE_LEVEL_FILE=0" to the database URL. But it would make sense to not create exceptions at all; I wonder if this is really a Hibernate bug.

Regards,
Thomas




--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Thomas Mueller

unread,
Mar 25, 2014, 2:45:05 AM3/25/14
to H2 Google Group
Hi,

In future versions of H2, the stack trace of this exception will no longer be logged by default.

Regards,
Thomas
Reply all
Reply to author
Forward
0 new messages