NPE after using new property h2.lobInDatbase=true

9 views
Skip to first unread message

Prowler

unread,
May 19, 2010, 4:56:10 AM5/19/10
to H2 Database
Hello Thomas,

Since this is my first post I would like to congratulate you for your
excellent work
and hope to see commercial support offerings soon.

Now to the point, I was testing out the new property h2.lobInDatabase.
After enabling and adding some blobs successfully, when I try to query
the objects through JPA (Hibernate) I got the following exception:

Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: could not execute query
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1235)
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1168)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:250)
at
com.vis.core.module.persist.JpaFormSaveBroker.getSubmits(JpaFormSaveBroker.java:
185)
... 16 more
Caused by: org.hibernate.exception.GenericJDBCException: could not
execute query
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:
140)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
128)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
66)
at org.hibernate.loader.Loader.doList(Loader.java:2297)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
at org.hibernate.loader.Loader.list(Loader.java:2167)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:448)
at
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:
363)
at
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:
196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:241)
... 17 more
Caused by: org.h2.jdbc.JdbcSQLException: General error:
"java.lang.NullPointerException" [50000-135]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.message.DbException.convert(DbException.java:279)
at org.h2.message.DbException.toSQLException(DbException.java:252)
at org.h2.message.TraceObject.logAndConvert(TraceObject.java:387)
at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:988)
at org.hibernate.type.AbstractBynaryType.get(AbstractBynaryType.java:
103)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:186)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:175)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:105)
at
org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:
2267)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1423)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1351)
at org.hibernate.loader.Loader.getRow(Loader.java:1251)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:619)
at org.hibernate.loader.Loader.doQuery(Loader.java:745)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
270)
at org.hibernate.loader.Loader.doList(Loader.java:2294)
... 25 more
Caused by: java.lang.NullPointerException
at org.h2.store.LobStorage$LobInputStream.<init>(LobStorage.java:171)
at org.h2.store.LobStorage.getInputStream(LobStorage.java:300)
at org.h2.value.ValueLobDb.getInputStream(ValueLobDb.java:271)
at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:220)
at org.h2.value.ValueLobDb.getBytes(ValueLobDb.java:207)
at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:986)
... 37 more


Best regards,
Panayiotis Vlissidis

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

Thomas Mueller

unread,
May 20, 2010, 4:08:43 PM5/20/10
to h2-da...@googlegroups.com
Hi,

I have a question. What is your database URL? Is it possible that the
connection is closed already when trying to read the lob? I'm
wondering how I could reproduce the problem...

Regards,
Thomas

Panayiotis Vlissidis

unread,
May 21, 2010, 8:15:59 AM5/21/10
to h2-da...@googlegroups.com
Hello Thomas,

My url is : jdbc:h2:file:/path_to_file;DB_CLOSE_DELAY=-1

I noticed though that this issue is most probably caused  in case where 
the table contains mixed data (i.e some lobs stored in files and others internally)
which did happen in my case since I did not useSCRIPT and RUNSCRIPT before testing out 
the feature.

Hence you can replicate by doing the following:
1) Start with h2.lobInDatabase=false, create a table that contains a lob column and insert some data
2) Close the DB. Start again with h2.lobInDatabase=true and store some more data
3) When trying to select all of the rows then the exception occurs.

Hence it is most probably my fault that I did not re-created the database before testing out the new feature
 and I guess you are not planning to support mixed modes on this.

Thanks for your time,
Best regards,
Panayiotis Vlissidis

Thomas Mueller

unread,
May 25, 2010, 3:54:58 PM5/25/10
to h2-da...@googlegroups.com
Hi,

I can now reproduce the problem, but my test case is doing the exact
opposite to what you described:

1) Set h2.lobInDatabase=true, create a database and insert a BLOB or CLOB.

2) Stop the application, and then try to read the BLOB/CLOB with
h2.lobInDatabase disabled

I get exactly the same stack trace.

I didn't think about this case... It's an edge case but it should
work. I will fix this in the next release.

Regards,
Thomas

Prowler

unread,
May 26, 2010, 6:27:01 AM5/26/10
to H2 Database
Hi,

Well yes it is the opposite but the final result is the same I guess,
i.e you can not have mixed data (i.e some lobs stored in files and
others
internally) at least for the same table. It would be best to create a
unit test
for both cases I guess.

Best regards,
Panayiotis Vlissidis

Reply all
Reply to author
Forward
0 new messages