Unlikely Teacher

1. Share Everything* [Programming Gotchas, Technology News, Insights on Living and Everything in Between]

TopLink JPA and HSQLDB Quirk

May 14th, 2008 · 8 Comments · Java

I discovered a weird issue when using HSQLDB as database provider for TopLink JPA.

We need to explicitly include the toplink.target-database property in the persistence.xml file to make it work.

<property name="toplink.target-database" value="HSQL"/>

Without that, you are most likely to get this error below when you run your application:


Query: DataModifyQuery()
	at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:304)
       ...
Caused by: java.sql.SQLException: Table not found in statement

I did not have that property set when I was using TopLink JPA with MySQL so I was a bit surprised why it was not working initially when I switched to HSQLDB.

Anyway, here’s the complete properties element of persistence.xml for HSQLDB for your reference:

      <properties>
         <property name="toplink.ddl-generation" value="drop-and-create-tables" />
         <property name="toplink.jdbc.driver" value="org.hsqldb.jdbcDriver" />
         <property name="toplink.jdbc.url" value="jdbc:hsqldb:notifications" />
         <property name="toplink.jdbc.user" value="sa" />
         <property name="toplink.jdbc.password" value="" />
         <property name="toplink.target-database" value="HSQL"/>
      </properties>

Hope I can save you guys a lot of trouble through this post.

Because it certainly took me hours to figure this thing out.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • StumbleUpon
  • Tumblr
  • Twitter

Tags: ··

8 Comments so far ↓

  • minanov

    Hmm, that is interesting
    I am suing HSQLDB too with Toplink Essentials.

    Thanks

  • Indian

    Thanks a lot!! it works fine :o )

  • jadrake

    This proved to be very helpful in setting up my unit tests. I linked my blog to this blog entry.

  • HSQLDB and java entity class most common error

    [...] Before i looking many hours in Google i find the solution thanks to this web [...]

  • Rama

    hi..
    I want to use hsql database along with glassfish for persisting data.But I am facing some problems with configuration.
    can u please tell what is required configuration for setting up a connection pool.
    I created a pool using username,password and url properties..but whne i try to ping its giving exception saying Connection Object cant be NULL.

    please help me..

  • dayg

    Sorry Rama but this looks like a Glassfish issue which I’m not very familiar with.

    Did you try following the steps from this post?

    HTH.

  • Bertrand

    hi,

    where we can see insert in the table?

  • andresmoreira

    Thank you man! I’ve been working for around and hour in this bug, and then I’ve found your solution in Google!
    Thanks again

Leave a Comment