HSQLDB with Hibernate: addScalar

{% include JB/setup %} To continue this series, I just have another little cautionary bit of advice regarding using addScalar with your createSQLQuery(...) operations. In MySQL, a query like this: SELECT obj.name, other.name, third.name FROM obj, other, third Will give the full name of those columns in the “result set metadata” that Hibernate accesses. So when you use addScalar, you can just say: .addScalar("obj.name") .addScalar("other.name") .addScalar("third.name") However, in other database engines the columns might come back in the metadata as [ name, name, name ]; when you try to use addScalar with the full path, you will get an error. (I don’t believe that just calling addScalar once with “name” will apply to each of the three occurrences either, but I haven’t checked). ...

September 18, 2013 · 1 min

HSQLDB with Hibernate: User lacks privilege or object not found

{% include JB/setup %} I’m currently working to add unit tests to a project which currently has no tests for its database query layer. Normally I wouldn’t worry too much, but there are some nasty queries that have cropped up over the years that could benefit from some testing. This project uses Hibernate and the custom queries are written mainly in some MySQL-specific language. Part of the problem with adding tests has been that the hbm2ddl tool hasn’t been able to reliably generate the database schema due to some strange approaches to ID generation and other MySQL-specific code. ...

September 18, 2013 · 1 min