I have several collections of lookups such as countries and states. I'd like to rely on the second level cache for these; however, I'm noticing that it appears to requery the database everytime instead of using the cache. For example, my Country class has the following annotations:
@Entity @NamedQueries({ @NamedQuery(name="allCountries", queryString="from Country") }) @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
manager.createNamedQuery("allCountries").getResultList();
you'll have to use the Hibernate Query API (check the hibernate doc on that subject).