Database Migrations And Java

February 23, 2013

There’s a trivial problem that every project has – keeping the database structure in sync with the application. That is, when your code relies on a new table or column, that table/column must appear in the database. This is especially a problem when there are multiple environments, on which the code gets deployed (production, stage, […]


Caveats With MySQL Pagination

January 22, 2013

We’ve all done pagination – it’s sensible for both lists in the UI and for processing data in batches. “SELECT (columns) FROM table LIMIT X, Y”. Possibly “SELECT (columns) FROM table ORDER BY some_column LIMIT X, Y”. What’s the caveat? Especially when working with an ORM and when processing batches, where order doesn’t matter, you […]


Tip Of The Day: Make Your Email Column Unique

November 14, 2012

Skype screwed up and it got revealed today. Due to a series of stupid things, there is (was) a trivial way to hijack anyone’s account. One of the stupid things is that they allowed a 2nd user to register with an email that is already registered. I have seen this many times, with forums, groupon-like […]


How To Generate A Schema Creation Script With Hibernate 4, JPA And Maven

July 26, 2012

The scenario is trivial – you want to generate a database schema creation script while building your application (and then execute the script on the target database) This was relatively easy with Hibernate 3, as there was the hibernate3-maven-plugin, but it is not compatible with Hibernate 4. And for every new project you should start […]


ORM Haters Don’t Get It

May 9, 2012

I’ve seen tons of articles and comments (especially comments) that tell us how bad, crappy and wrong is the concept of ORM (object-relational mapping). Here are the usual claims, and my comments to them: “they are slow” – there is some overhead in mapping, but it is nothing serious. Chances are you will have much […]


Are Tests of Service Methods That Rely on Database Access Unit Tests?

December 29, 2009

It is often argued whether tests that need a database should be called “unit tests”. Most often the answer is “No, these are database integration tests”. My opinion is – “Yes”. The whole problem is routed in the fact that service methods depend on data access. If an application is designed properly the data access […]


Database Integration Testing / Unit-Testing with Spring, JPA, JUnit and Maven

November 22, 2009

The exact name for this tests is disputable. Whether it should be “database integration testing” or “unit testing”. But anyway, it is about this: Many applications’ service layer relies heavily on database operations (through a JPA provider, for example), even though the access to the database is abstracted in a DAO layer. An option for […]