Last week I’ve been playing around with Google App Engine (GAE). Setting up the SDK with Eclipse and the Google Plugin for Eclipse was a breeze. Creating a simple webapp, testing it locally, and deploying it to appspot was a piece of cake. But then I figured I wanted to add a REST interface to my application… Continue reading “JAX-RS on Google App Engine”
Gotcha: preserving the ordering in collections when using JPA
This week I was faced with the requirement to store the ordering of a collection from a Java web application to a database. In plain Java, retaining the ordering within a collection is a no-brainer: you just use one of the java.util.List
implementations. And saving the order into a database table should be as easy as a couple of INSERT
statements in the correct order, right? Well, if you’re using JPA for ORM then it really isn’t that straightforward. As it turns out JPA does not take the ordering of a List
into consideration, which imho is a serious design flaw. Forunately, as of version 2.0 a workaround was added to the spec: you can annotate relationships with @OrderColumn
.