Hibernate problem with reserved SQL keyword

2011/01/31

I ran into a stupid problem yesterday when I was trying to setup Spring + Hibernate with HSQLDB. Everything looked fine except it didn’t work… The error I got was the following:

org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: [com.company.domain.Payment]; bad SQL grammar [insert into Payment (paymentId, customerId, orderId, paymentReferenceNumber, sum, validTransactionDate) values (null, ?, ?, ?, ?, ?)]; nested exception is java.sql.SQLException: Table not found in statement [insert into Payment (paymentId, customerId, orderId, paymentReferenceNumber, sum, validTransactionDate) values (null, ?, ?, ?, ?, ?)]
The error might be obvious to the reader, but it was not for me… A column can’t be named ‘sum’ –  it’s a reserved word in SQL.
Hibernate has the ability to autocreate tables for you but it said eaxactly nothing about failing to do so.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: