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”

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”