Java, Equality, Mutability

TL;DR version: Don’t implement equals() on mutable objects.

This is a post I’ve been tossing around for a couple of years, ever since a lunchtime debate with a colleague. It’s a simple statement: You shouldn’t implement the equals() method if your object isn’t immutable.1

Continue reading “Java, Equality, Mutability”

Hibernate Query (Lack Of) Caching

Hibernate has long had a feature known as “query caches” – you can run a query, cache the result, and thus avoid running it repeatedly. The only problem is that it doesn’t do what you think it does.

Continue reading “Hibernate Query (Lack Of) Caching”

ehcache dissected

At work, we are a heavy user of ehcache. Well, we would be… it was initially written at Wotif, to overcome problems with the Jakarta JCS project. I recently had to sit down and figure out exactly how it works, and thought I’d take a moment to write it up.

*Update*: I tested the Hibernate serialization behaviour. See below for more.

Continue reading “ehcache dissected”

Differences in behaviour between Hibernate delete queries and the old way

In Hibernate 2, you could sort-of do a bulk delete via the Session interface. In Hibernate 3, they have true bulk deletes, ala Section 3.11 of the EJB 3 Persistence API. However, they have some significant differences which people migrating to the new functionality need to be aware of.

Continue reading “Differences in behaviour between Hibernate delete queries and the old way”

Upgrading to Hibernate 3 – a war story

I finally got a chance to try out upgrading to Hibernate 3 at work. It wasn’t the smoothest of rides, but I got there in the end.
Continue reading “Upgrading to Hibernate 3 – a war story”

How the new Hibernate bulk queries work

When I gave my talk on Monday I’d sort of hurried over the new bulk queries in Hibernate, largely because I didn’t have much luck finding doco on them.

Now I know how they work.

Continue reading “How the new Hibernate bulk queries work”

New features of Hibernate 3.0

I gave a talk at the AJUG-QLD tonight on the new features of Hibernate 3.0.
Here are the slides

Continue reading “New features of Hibernate 3.0”

Remember to read the errata!

I’d introduced a Hibernate user type into the code base a few days ago. I’d based it on an example in the (more or less) wonderful book Hibernate in Action Naturally, however, I’d copied the example with a bug in it!

Continue reading “Remember to read the errata!”

Another good use for named queries

A while back, I blogged about how Hibernate named queries rock I found another reason why they rock today: it lets you hide what your persistent properties are called.

Continue reading “Another good use for named queries”