Software firms around Bristol

An old colleague of mine put together a map on Google Maps showing software firms around the Bristol area.  Very useful if you’re searching for a job.,-2.587452&spn=0.03744,0.072956&z=13&source=embed



Adding code snippets within posts

I’m always looking to put code snippets inside of my posts, and sometimes it can be a bit fiddly getting the formatting right.  I discovered a site today – – which allows you to paste in code, and generates html for you which you can then put into your blog post.  Hopefully that should make things a little easier!  🙂

Eclipse updates with Java 7

I recently pulled down the latest Java (v. 7 upate 2).  I’m currently using Eclipse Indigo as my IDE, and I found that I was then unable to install any new plugins from update sites.  I kept getting read time out errors.

Once I moved back to Java 6 upate 30, the problem went away.  Worth noting if you’re planning to move to Java 7 in the near future.  Hopefully this will be fixed in later versions of Eclipse.

JPA and Apache Derby

I have a Derby database, and I’m looking to query and update it from a java application. I’m using JPA to handle this. My persistence.xml file is as follows:

<persistence xmlns=""

    <persistence-unit name="test">


            <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:derby:/home/dan/Derby/db1;create=true" />
            <property name="javax.persistence.jdbc.user" value="" />
            <property name="javax.persistence.jdbc.password" value="" />

            <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
            <property name="hibernate.show_sql" value="true" />



In order to query a single entity from the database, I use the find method provided by EntityManager:

TestEntity entity = entityManager.find(TestEntity.class, id);

When updating records in the database, we use the merge method provided by EntityManager:


When creating a new record, we use the persist method:


Eclipse Databinding Decoration

On a wizard I’ve developed, I’ve made use of the Eclipse databinding framework to bind UI widgets to the model behind the wizard.  This framework generally works pretty well, but I was having issues when I wanted to hide the decoration of a control based on the selection of other controls in the wizard.

So here’s the situation:  I have a text control, and I have created a validator on the control which returns an error status if the text control is empty.  I have set the default decoration on the text control. 

I also have a checkbox on the wizard.  If it isn’t checked, I set the text control to be disabled.  If the control is disabled, I want its decoration to be hidden.

It turns out this is harder than expected.  In the end, the strategy I adopted was as follows:

I created my own control decoration updater:

class CustomControlDecorationUpdater extends ControlDecorationUpdater {
  private ControlDecoration controlDecoration;
  private IStatus lastStatus;
  private boolean showValidation = false;

  protected void update(ControlDecoration decoration, IStatus status) {
    if (this.controlDecoration == null) {
      controlDecoration = decoration;
    this.lastStatus = status;
    super.update(decoration, status);
    if (!showValidation) {

  public void setShowValidation(boolean show) {
    this.showValidation = show;
    if (controlDecoration == null || lastStatus == null) {
    update(controlDecoration, lastStatus);

This control decoration updater allows me to tell it whether to hide the decoration. Now I add a listener to my checkbox which controls whether the text control is enabled.

button.addSelectionListener(new SelectionAdapter() {

  public void widgetSelected(SelectionEvent e) {

Reverting change using Gerrit

The development environment we have on my current project is pretty good – we’re using the Jenkins (Open source Hudson) continuous integration system, and we’re using the Git version control system.  This is a distributed version control system, so we push commits to a remote repository once we’re happy with them.  Using a distributed system like Git allows us to use Gerrit to mandate that commits are code reviewed before they are submitted to the remote repository.

So the system allows to spot most mistakes early, Jenkins ensures that the code builds and all the tests pass.  Forcing a code review means that you get at least one other pair of eyes on your code before it is submitted.

If, despite all these checks, something makes it onto the remote master branch which causes problems at run time, what are your options to fix things?

A strategy I have used is to rebase my local version of master so that it no longer contains the offending commit, and then force push to the remote machine, so that the remote repository no longer contains it.  However, if other users have already pulled from master, then their local commit histories will already contain the offending change.  When they push, the offending change will also be pushed to Gerrit along with their changes.

Fortunately, Gerrit comes to your rescue with the “Revert Change” button which can be applied to changes which have already been submitted.  This adds a new commit to Gerrit which undoes the effect of the change which you are looking to revert.