Unlikely Teacher

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

TopLink JPA and HSQLDB Quirk

May 14th, 2008 · 7 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: ··

7 Comments so far ↓

Leave a Comment