hibernate-pains-selects-query-cache

Hibernate Gotchas and Growing Pains

This blog entry is a TODO, but I wanted to have a place to jot down a few pains with Hibernate and how to remedy them.

1. @ManyToOne id references result in a query by default.

Eg:

class Dog {
protected @ManyToOne owner;
}

Dog dog = entityManager().find(Dog.class, 1);
System.out.println(dog.owner.id); // This results in the Owner class being queried which is not necessary.

The basic solution which I will detail out later is to set property access on the id attribute of Owner, while leaving everything else the default (field).

2. The nasty query cache.

Syndicate content