Marc Schwieterman

Backing Up Your Personal Website

6 minute read Published:

Most website hosting companies do their own backups, but they often make no guarantees about actually recovering your data. If you put any amount of effort into a website, you really owe it to yourself to have a decent backup and recovery strategy. You don’t have to do anything too fancy or complicated, but at a minimum you should backup your home directory with tar and any databases that your website uses.

Eclipse Generated Equality

4 minute read Published:

Most users of Eclipse are familiar with its code generation features. One of the more common of these is “Generate hashCode() and equals()…” from the right-click -> Source (⌘-Opt-S) menu. It roughly follows the recipe on page 33 of Joshua Bloch’s Effective Java, and it is effective in most situations. One case where it doesn’t work is when the class is proxied. Hibernate is just one example of a framework that generates proxies. If the Person class below were proxied, the default Eclipse implementation of equals() would break. In a Hibernate application, this can lead to anything from unnecessary deletes and inserts to some very frustrating bugs.

Liquibase and the modifySql Tag

3 minute read Published:

Liquibase is a tool that helps you manage database changes. It can can be integrated into your build process to automatically update your database, and it also has a command line interface that operational staff can use to generate SQL scripts for production deployment. One of its nice features is database abstraction. You define your changesets in XML, and Liquibase generates compatible SQL for you. As with any tool that tries to provide this level of abstraction over a large number of vendors, it doesn’t work 100% with all DBMS. Below is a simple changeset.

Getting Started with Xcode

4 minute read Published:

I finally spent some quality time with Xcode this past weekend. While I haven’t done any real work with it yet, I think it should be a serviceable IDE. The current version of Xcode at the time of this writing is 3.2.3, and it can be downloaded for free from Apple. You do have to register an account if you don’t have one yet, but you don’t have to pay anything until you want to join the iPhone Developer Program. You can’t actually install anything on a mobile device until you subscribe, which mainly gives you a one year certificate that you use to sign your applications.

Maven Transitive Dependency Filtering

2 minute read Published:

The other day I wrote a post about examining dependencies in maven plugins. Today I was working on a similar project, and I discovered some non-intuitive behavior with the Maven ArtifactResolver. Several of the resolveTransitively methods accept an ArtifactFilter, but the filter gets applied in an odd way.

Hibernate: Automatic Versioning

3 minute read Published:

One of the optimistic locking features that Hibernate provides is automatic versioning. Versioned objects need to contain either a version or timestamp property that Hibernate uses to detect concurrent modifications at flush time. Hibernate’s versioning mechanism works by checking the number of rows that were affected by an update statement. Consider an accounts table like the one below.

Examining Dependencies in Maven Plugins

2 minute read Published:

After you’ve worked with Maven for a while, you’ll eventually find a need to extend it. While there are some means of executing arbitrary code as part of your build, the best way to handle such needs is to create a maven plugin. The task may seem a bit daunting at first, but you’ll learn a lot about how maven works by doing it. Listed below are the properties that you need to define to examine the dependencies of a maven project from within a plugin. The following code would be placed inside a Maven Mojo.

Getting Files onto the iPad

2 minute read Published:

The lack of a file system on the iPad and other iOS based devices can sometimes be frustrating. While applications like Dropbox make accessing your existing files trivial, getting new files onto your device directly from the web is not as easy. If you come across a PDF or other file that you’d like to open in a local application, you may be out of luck.

Simple Stub Creation with Mockito Partial Mocks

3 minute read Published:

When testing code that interacts with lower layers, I often stub out the lower layer to return objects to the code that I’m actually testing. I mostly use stubs generated by a mocking framework, but I occasionally come across cases where the stub needs to do something other than just return a known object. Take the case of a DAO that assigns a generated identifier to a domain object. Here we see a service that takes a name, creates a User object with it, persists the object and returns the generated id to the caller.

MarsEdit: Preview with SyntaxHighlighter

1 minute read Published:

I’ve recently been trying out the MarsEdit blog editor. One issue I’ve run into is that SyntaxHighlighter doesn’t work with the preview feature because the page in the preview window only gets loaded once. Fortunately there is a workaround. A typical SyntaxHighlighter configuration will look similar to the code fragment below.